ProcessReturnCode Issue

Post Reply
PlanningDev
Community Contributor
Posts: 349
Joined: Tue Aug 17, 2010 6:31 am
OLAP Product: Planning Analytics
Version: 2.0.5
Excel Version: 2016

ProcessReturnCode Issue

Post by PlanningDev »

I have been trying to use the process return code in the epilog of an executing TI to determine if the process executes successfully. Unfortunately even when I create a TI that I know will have minor errors, it is still returning normal.

Executing this in the epilog of the running TI is not working

Code: Select all

NumericGlobalVariable('ProcessReturnCode');

if(ProcessReturnCode <> ProcessExitNormal() );

TextOutput('E:\Test.txt.','ERROR', NumberToString(ProcessReturnCode));

endif;
Now if I create a second TI and use this code to execute the orignal TI it works

Code: Select all

return_value = ExecuteProcess('DELETE');

if(return_value <> ProcessExitNormal() );

TextOutput('E:\Test.txt.','ERROR', NumberToString(return_value));

endif;
Shouldn't it produce the same result either way?
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: ProcessReturnCode Issue

Post by rmackenzie »

In the first script, from what you've posted, you didn't call a process (via ExecuteProcess) such that it would set the global variable (ProcessReturnCode) to something other than zero. Zero happens to be the return code where the process ran successfully so it isn't generating the error message. Try something like this:

Code: Select all

NumericGlobalVariable('ProcessReturnCode');

### new line - this process should set the ProcessReturnCode global variable
ExecuteProcess('DELETE');
#################################################################

if(ProcessReturnCode <> ProcessExitNormal() );

TextOutput('E:\Test.txt.','ERROR', NumberToString(ProcessReturnCode));

endif;
Robin Mackenzie
PlanningDev
Community Contributor
Posts: 349
Joined: Tue Aug 17, 2010 6:31 am
OLAP Product: Planning Analytics
Version: 2.0.5
Excel Version: 2016

Re: ProcessReturnCode Issue

Post by PlanningDev »

I was hoping to not have to call the process I want to run from another process everytime. Is it not possible from within a single TI to determine if it executed successfully? Otherwise I have to use 2 TI's just to determine if the TI ran successfully. Or can a global TI be created that can be called in the epilog of a running TI to check if it ran successfully?
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: ProcessReturnCode Issue

Post by Alan Kirk »

PlanningDev wrote:I was hoping to not have to call the process I want to run from another process everytime. Is it not possible from within a single TI to determine if it executed successfully? Otherwise I have to use 2 TI's just to determine if the TI ran successfully. Or can a global TI be created that can be called in the epilog of a running TI to check if it ran successfully?
You can always do what we do; we use a control cube. When each process /chore starts you can clear the success flag in that cube, then write it back as the last thing done in the last epilog of the last process. If you need to know whether the thing completed successfully, just check that cell in the control cube.

(It's actually a little more complicated than that in our case since we also determine the number of rejects, but you can make it as simple or as complex as you need it to be. However if the process or chore crashes then that flag will never be written to the control cube, and you'll know that the process failed.)
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
PlanningDev
Community Contributor
Posts: 349
Joined: Tue Aug 17, 2010 6:31 am
OLAP Product: Planning Analytics
Version: 2.0.5
Excel Version: 2016

Re: ProcessReturnCode Issue

Post by PlanningDev »

Technically what I would like to do is check every process for success after it finishes. The reason is that we have certain metadata updates logically grouped in different chores, but I need the chore to be killed and an e mail to be sent for which TI failed with the error logged attached.

The reason why I wanted to embed this in each TI is so that I don't have double the number of TI's. IE 1 to start the process and capture the status and 1 to actually do the work. It's not looking like the all in one is possible though.
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: ProcessReturnCode Issue

Post by rmackenzie »

PlanningDev wrote:Technically what I would like to do is check every process for success after it finishes
Now I see that you are trying to 'share' the ProcessReturnCode between processes and you expect that its value is set in the Epilog. I don't think it's going to work setting a protected variable name as a global variable because it is already (per the doco) an 'implicit global variable'. As I understand it, all processes have their own ProcessReturnCode. Also, I don't actually think it has a value in the Epilog as errors could still be generated there or forced with ProcessQuit etc.

Alan's method is preferable and you can add more detail to the feedback by referencing MetadataMinorErrorCount and DataMinorErrorCount etc etc.
Robin Mackenzie
Post Reply