Before we start, We should know- What is COND in JCL?
You can set the COND parameter at –
COND[.procstepname]=(rc,logical-operator) or COND[.procstepname]=(rc,logical-operator[,stepname][.procstepname]) or COND=EVEN or COND=ONLY
Description of parameters in syntax:
|Type 1||COND=(0,EQ)||Is return code 0 equals the return code from the previous step? If this condition is true then bypass this step.|
|Type 2||COND=(4,EQ,STEP10)||Is return code 4 equals the return code from the previous step? if this condition is true then bypass this step.|
|Type 3||COND=EVEN||Run this steps even though, any of the previous step has Abended.|
|Type 4||COND=ONLY||Run this step only if any of the previous steps has abended.|
Example 1: COND Parameter at JOB level.
If you code a COND parameter at JOB level, then this condition will test against the return code of all the steps of the JCL.
//MATEKSD JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID, //* COND=(0,NE) //* EXAMPLE TO SHOW COND AT JOB LEVEL IN JCL //* //STEP01 EXEC PGM=CONDPGM1 //STEP02 EXEC PGM=CONDPGM2,COND=(0,EQ) //STEP03 EXEC PGM=CONDPGM3,COND=(4,EQ)
Explanation:COND parameter at the JOB level is – COND=(0,NE)
Example 2: COND Parameter at STEP level.
When COND is coded in EXEC statement of a job step and found to be true, only that job step is bypassed, and execution is continued from next job step.
//CNDSAMP JOB CLASS=6,NOTIFY=&SYSUID //* //STP01 EXEC PGM=SORT //* Assuming STP01 ends with RC0. //STP02 EXEC PGM=MYCOBB,COND=(0,EQ,STP01) //* In STP02, condition evaluates to TRUE and step bypassed. //STP03 EXEC PGM=IEBGENER,COND=((10,LT,STP01),(10,GT,STP02)) //* In STP03, first condition fails and hence STP03 executes. //* Since STP02 is bypassed, the condition (10,GT,STP02) in //* STP03 is not tested.
Example 3: JCL COND=EVEN
If you want to execute a particular step even if any of the previous steps have Abended, then you should use – COND=EVEN in that step.
//MATEKSD JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID //* //* EXAMPLE TO SHOW COND=EVEN IN JCL //* //STEP01 EXEC PGM=CONDPGM1 //STEP02 EXEC PGM=CONDPGM2 //STEP03 EXEC PGM=CONDPGM4,COND=EVEN
COND=EVEN will test – STEP03 will run even if STEP01 or STEP02 has Abended. So, irrespective of whether STEP01 or STEP02 has Abended or not, STEP03 will run.
Example 4: JCL COND=ONLY
If you want to execute a particular step only and only if any of the previous steps have Abended, then you should use – COND=ONLY in that step.
//MATEKSD JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID //* //* EXAMPLE TO SHOW COND=ONLY IN JCL //* //STEP001 EXEC PGM=ONLY3PGM //STEP002 EXEC PGM=ONLY2PGM //STEP003 EXEC PGM=ONLY1PGM,COND=ONLY
There can be multiple COND Parameter in JCL but a maximum of 8 COND parameter is allowed.
COND parameter can be used at JOB level or STEP level or at both the places.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!