Page 1 of 1

TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Sun Mar 11, 2018 7:27 am
by ptownbro
I'm trying to run some TI processes in parallel by executing TM1RunTI from a batch file. It's successfully executing and running the process in parallel, however, I'm running into issues handling errors that may occur.

I'm doing it by running multiple successive "START" commands within the batch file. The commands in turn call the TM1RunTI utility and passes it different parameters.

The problem is when one of the calls has an error, none of the calls afterward work. And I don't know how I can catch the errors so that I know something wrong happened in the first place.

Here's what my batch file looks like for example:

Code: Select all

echo off
pause
START c:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "D:\TM1\Example\RunProcess.ini" -process "BuildDim" pDim="Dim1"
START c:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "D:\TM1\Example\RunProcess.ini" -process "BuildDim" pDim="Dim2"
START c:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "D:\TM1\Example\RunProcess.ini" -process "BuildDim" pDim="DimDoesNotExist"
START c:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "D:\TM1\Example\RunProcess.ini" -process "BuildDim" pDim="Dim4"
If in my example, the "DimDoesNotExist" dimension doesn't exist, then the third line will have an error. However, no error message is returned and the fourth line doesn't run.

How can I get it to continue to run regardless of it there is an error?
How can I capture the error or know that an error occurred?
Is there a better way to do this besides a batch file?

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Sun Mar 11, 2018 10:18 am
by gtonkin
Not sure if you have come across the Using TM1RunTI guide but based on the fact that you are using an INI file, you may have.
What you need to do in your batch file is to use ERRORLEVEL - this variable will give you the return codes after executing the TM1RunTI command.
Have a look here for more on error trapping and more batch file examples.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Sun Mar 11, 2018 5:52 pm
by ptownbro
Thanks. I did read the users guide, but didn't catch that part. Anyway, I'll try it out and report back.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Wed Apr 18, 2018 7:02 pm
by ptownbro
I finally got around to trying this again and I could not get the ERRORLEVEL method to work. Here's what I have.

First, I created a simple TI process to create a dimension with 3 elements in it. In the the script line to add the 3rd element, I added an obvious error by supplying it the wrong element type.

Code: Select all

MyDimension = 'Test Error Handling';
DIMENSIONDESTROY(MyDimension);
DIMENSIONCREATE(MyDimension);
DIMENSIONSORTORDER(MyDimension,'','','BYHIERARCHY','ASCENDING');
DIMENSIONELEMENTINSERT(MyDimension, '', 'Item 1', 'n');
DIMENSIONELEMENTINSERT(MyDimension, '', 'Item 2', 'n');
[b]DIMENSIONELEMENTINSERT(MyDimension, '', 'Item 3',[i] 'x'[/i]);[/b]
The TM1RunTI configuration file I created has the following:

Code: Select all

[TM1RunTI]
process = Test Error Handling
connect = Main

[Process - Test Error Handling]

[Connect - Main]
adminhost = myserver.mydomain.com
Server = MyTM1Server
user = admin
pwd = apple
The batch file has the following: (I blew it out to see if I was missing something)

Code: Select all

echo off
echo You are about to run the Test Error Handling process. Are you sure you want to continue?
pause

START C:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "C:\TM1\MyTM1Server\Test\RunTM1Process.ini" -process "Test Error Handling"

IF ERRORLEVEL 0  GOTO ERR00
IF ERRORLEVEL 1  GOTO ERR01
IF ERRORLEVEL 2  GOTO ERR02
IF ERRORLEVEL 3  GOTO ERR03
IF ERRORLEVEL 4  GOTO ERR04
IF ERRORLEVEL 5  GOTO ERR05
IF ERRORLEVEL 6  GOTO ERR06
IF ERRORLEVEL 7  GOTO ERR07
IF ERRORLEVEL 8  GOTO ERR08
IF ERRORLEVEL 9  GOTO ERR09
IF ERRORLEVEL 10 GOTO ERR10
IF ERRORLEVEL 11 GOTO ERR11
IF ERRORLEVEL 99 GOTO ERR99

pause
echo Um.. What happened?! You shouldn't be getting this message. You should have been taken to an error/message line below.
exit

:ERR00
echo no error
pause
exit

:ERR01
echo error 1
pause
exit

:ERR02
echo error 2
pause
exit

:ERR03
echo error 3
pause
exit

:ERR04
echo error 4
pause
exit

:ERR05
echo error 5
pause
exit

:ERR06
echo error 6
pause
exit

:ERR07
echo error 7
pause
exit

:ERR08
echo error 8
pause
exit

:ERR09
echo error 9
pause
exit

:ERR10
echo error 10
pause
exit

:ERR11
echo error 11
pause
exit

:ERR99
echo error 99
pause
exit
Given the above, I was expecting the command prompt to return an error code of above 0 or most likely error code "99" (which according to the TM1RunTI utility documentation is an unspecified error) to indicate the error in the "Test Error Handling".

Instead, it kept returning there was "no error" meaning that, if you look at my batch file script, the ERRORLEVEL is returning "0 "and then going to my line defined as ":ERR00" and returning (echoing) my "no error" message to the command prompt application.

I tried to provide it a non-existent process which I expected would return error code "6" according to the documentation, but it's still returning error code "0":

Code: Select all

START C:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "C:\TM1\MyTM1Server\Test\RunTM1Process.ini" -process "x_Test Error Handling"
I even tried to provide reverse the order of the error check (because I read that ERRORLEVEL returns errors 1 and above, so maybe it would return 0 and above? don't know) and that still returned error code "0":

Code: Select all

IF ERRORLEVEL 99 GOTO ERR99
IF ERRORLEVEL 10 GOTO ERR10
IF ERRORLEVEL 9 GOTO ERR09
etc...

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Thu Apr 19, 2018 6:02 pm
by gtonkin
Have a look at ERRORLEVEL is not %ERRORLEVEL% which may give you a bit more insight. I may only have some time to test out your batch file on the weekend to give more pointed advice.
HTH

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Thu Apr 19, 2018 9:06 pm
by macsir
Bat file is kind of clumsy. And I use powershell to wrap TM1RUNTI command. In other powershell file, you can use $LASTEXITCODE to capture what this TM1RUNTI returns.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Sat Apr 21, 2018 3:44 pm
by ptownbro
I read through the link tried using the variable instead of the internal reference and that still didn't work. For example, I change the error checking I had above to the following:

Code: Select all

IF %ERRORLEVEL%==0  GOTO ERR00
IF %ERRORLEVEL%==1  GOTO ERR01
IF %ERRORLEVEL%==2  GOTO ERR02
Etc...
It still returns my "no error" message as if the error level is zero. I know the process is it's throwing error and confirmed several times. In fact, you can see the error in the "tm1server.log" file.

I'm not sure why this is not working as instructions state the following:
To deal with errors, execute TM1RunTI from a batch script called by ExecuteCommand so that the error return code can be obtained in CMD.EXE through the ERRORLEVEL variable and so that error messages can be logged or intercepted by redirecting stderr.
To me that clearly means that I should be able to do what I"m trying but obviously I'm missing something because it's not working.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Sat Apr 21, 2018 3:57 pm
by gtonkin
HI ptownbro, just fired up my server-I was getting stuck at START C:\ibm... - exit code was 9059.
Try removing the START to see what you get: I am using:

Code: Select all

"C:\program files\ibm\cognos\tm1_64\bin64\tm1runti.exe" -i "C:\temp\RunTM1Process.ini"
I dropped the -p as this is already in the INI file.

You may also want to just add:

Code: Select all

echo Exit Code: %ERRORLEVEL%
This should at least tell you what the ERRORLEVEL is.

Give the above a try and post back your results.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Fri Apr 27, 2018 4:13 pm
by ptownbro
Ok. Remove the "START" does work and I'm seeing an error message now. And... You have to use the "%ERRORLEVEL%" environment variable instead of the internal "ERRORLEVEL".

HOWEVER... If you remove the "START" I can no longer run processes in parallel! Which the whole point behind our usage of TM1RunTI.

Need a solution that allows us to run items in parallel

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Fri Apr 27, 2018 5:41 pm
by gtonkin
Instead of START, try using

Code: Select all

cmd /c c:\ibm\cognos\tm1_64\bin64\tm1runti.exe -i "D:\TM1\Example\RunProcess.ini" -process "BuildDim" pDim="Dim1"... 
I have not tested with multiple statements but worth a try.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Fri Apr 27, 2018 6:41 pm
by ptownbro
Thanks for the suggestion. It worked, but unfortunately still does not run in parallel.

Re: TM1RunTI Parallel Processing with Batch File Error Capture

Posted: Fri Apr 27, 2018 6:59 pm
by gtonkin
There are some parameters for START - type in START /? at the command prompt - there may be something like the /I parameter that may work.

The other issue that comes to mind is with the multiple commands being run, you can have a return code from each of them. Even if you were to have separate batch files for each and use a CALL to run them, not sure that you can get the individual error codes back from each process.

Maybe another member can offer some advice where they have had more experience. Other than that, I will need to ponder and play around some more.