How to resubmit a job the number of times based on the completion code returned by the predecessor job.

Document ID : KB000046149
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction/Summary: 

How to resubmit a job the number of times based of the completion code returned by the predecessor job.

Background:  

Sometimes you may want to resubmit a job a certain number of times based on the completion or return code from a preceding job. So if the first job returns a 5, run the second job five times. If the job returns is a 3, run the second job three times, and so on.

Environment:  

This is applicable to all supported platforms.

Instructions: 

1. Use global variable and built-in variable WOB._cmpc to capture the exit code and pass the completion code between the jobs.
- In the predecessor job, set the Alert JavaScript script as below;

setVar('exitcode',WOB._cmpc);

2. In the job where you need the 'cmpc-value', execute a script at the job run time to assign the exit code to a WOB variable;

WOB.codeToUse = getVar('exitcode');

This way, the WOB.codeToUse variable would be available in the job to be resubmitted.

3. In the job which you need to resubmit 'cmpc-times', define an Alert with this JavaScript for example;

if (WOB._subcount < WOB.codeToUse)

execCommand(
'%WOB._name','%(APPL._name).%APPL._gen','ACTION RESUB');
}

Notes:

- The ‘<’ sign is used because the WOB.subcount starts from zero.
- The 'WOB.codeToUse' variable should have the WOB prefix so the Alert can recognize the variable.

- The 'cmpc-value' implies the job's completion code or exit code.

- The 'cmpc-times' implies the number of times based on the completion code. 

Additional Information:

Built-in Symbolic Variables

Global Variables

Examples Cookbook