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
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:
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;
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?
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.)
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.
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.