Wednesday 19 August 2015

COND Parameter

COND controls the execution of subsequent job steps based on the condition code of prior step.
This parameter can be coded in both JOB and EXEC statements. If this is the case, then Step COND will override the Job COND.
Maximum of 8 conditions can be coded in one COND parameter.
Return code will be between 0 to 4095.
Operators will be GT, GE, LT, LE, EQ, NE.
Syntax:
When coded in the Job statement,
COND=(Return code, operator)
Ex -
 //JOB1 JOB (A505),'EXAMPLE',CLASS=A
//          COND=(4,GT)
//STEP1 EXEC PGM=COBPGM1
//STEP2 EXEC PGM=COBPGM2
In the above example, if the return code of step 1 is greater than 4 then step2 will be bypassed.
When coded in the exec Statement,
COND=(Return-code,operator,step-name)
Ex -
 //JOB1 JOB (A505),'EXAMPLE',CLASS=A
//STEP1 EXEC PGM=COBPGM1
//STEP2 EXEC PGM=COBPGM2 (8,EQ,STEP1)
In the above example , if step1 return code is equal to 8, then condition will get satisfied and step2 will be bypassed.
If we do not specify step-name, the return codes of all previous steps will be checked. On comparison, if the condition is true then all the following steps are bypassed.
COND=ONLY
The job step which has the COND parameter coded like this will execute only if any of the prior step gets abended.
COND=EVEN
The job step which has the COND parameter coded like this will execute regardless of prior step abends.
Example of COND when coded multiple conditions
Ex -
 //JOB1 JOB (A505),'EXAMPLE',CLASS=A
 //STEP1 EXEC PGM=COBPGM1
 //STEP2 EXEC PGM=COBPGM2,COND=((16,GE),(90,LE,STEP1),ONLY)
STEP2 executes only when (any of the conditions coded in COND becomes false)
previous steps(here only step1) return code is 17 or higher OR return code of STEP1 will be 89 or less OR if STEP1 fails abnormally (for ONLY)
STEP2 gets bypassed when (any of the conditions coded in COND becomes true)
return code of previous step(s) will be 16 or less OR return code of STEP1 will be 90 or more OR when the previous step runs successfully.

No comments:

Post a Comment