How to use JCL Cond Parameters to skip a step in a Job
Cond Parameters are used in Job steps to route the job execution of each steps or a particular step. For example if you want to skip a particular step based on previous steps outcome, using a COND parameter is a good solution. COND Parameters can be coded at step level or the job levels and based on the return codes the execution can be altered.
COND Parameters comes handy when there are dependent job steps are present and they are interrelated. If a COND parameter is coded at JOB level, then the condition will be checked for every step except the first step. Return code of the predecessor step will be evaluated for the condition check.
Is there any alternative for COND Parameter
Instead of COND parameter you can also use “If then else” in JCL . If-then-else statements has its own advantage as it’s more controlled and gives additional flexibility on structuring the job execution.
COND Syntax in JCL
Below is the basic syntax of COND parameters in JCL.
COND=(Return Code ,logical-operator)Logical Operator can be GT (Greater Than), GE (Greater than or Equal to), EQ (Equal to), LT (Lesser Than), LE (Lesser than or Equal to) or NE (Not Equal to).
COND=(Return Code ,logical-operator, step name)
Sample JCL using IF-THEN-ELSE in JCL
//JOBSAMP JOB CLASS=6,NOTIFY=&SYSUID,COND=(5,LE)
//STEP010 EXEC PGM=STEP100
//* STEP010 executes without any test being performed.
//STEP020 EXEC PGM=STEP200
//* STEP020 is bypassed, if RC of STEP010 is 5 or above.
//* Say STEP010 ends with RC4 and hence test is false.
//* So STEP020 executes and lets say it ends with RC16.
//STEP030 EXEC PGM=SORT
//* STEP030 is bypassed since 5 <= 16.
Sample JCL using COND Parameter at Step Level in JCL
//JOBSAMP JOB CLASS=6,NOTIFY=&SYSUID
//STEP01 EXEC PGM=SORT
//* Assuming STP01 ends with RC0.
//STEP02 EXEC PGM=MYCOBB,COND=(0,EQ,STEP01)
//* In STEP02, condition evaluates to TRUE and step bypassed.
//STEP03 EXEC PGM=IEBGENER,COND=((10,LT,STEP01),(10,GT,STEP02))
//* In STEP03, first condition fails and hence STEP03 executes.
//* Since STEP02 is bypassed, the condition (10,GT,STEP02) in
//* STEP03 is not tested.