Menu
CoddyTech

COND

Part of the Batch Jobs with JCL section of Coddy's COBOL Programming journey. Lesson 10 of 19.

COND on an EXEC statement decides whether a step is bypassed:

//POST     EXEC PGM=POSTTXN,COND=(4,LT)

It reads: bypass this step if 4 is less than the return code of an earlier step.

The test names when to skip, not when to run, which makes it read backwards. COND=(4,LT) runs the step only when every earlier step ended with 4 or less. The operators are GT, GE, EQ, NE, LT and LE.

A step name makes the test look at that step only:

//FIX      EXEC PGM=FIXBAL,COND=(4,GT,CHECK)

This bypasses FIX when 4 is greater than CHECK's code, so it runs when CHECK ended with 4 or more. Up to 8 tests go in parentheses, COND=((4,LT),(0,NE,LOAD)), and any true test bypasses the step.

A bypassed step gets its own message and no return code:

IEF202I CONDJOB POST - STEP WAS NOT RUN BECAUSE OF CONDITION CODES
challenge icon

Challenge

Easy

CHECK ends with 8 when many balances are bad, and then POST must not run. Add a COND to POST's EXEC that bypasses it when an earlier step ended above 4. DAYEND still runs.

Try it yourself

//CONDJOB  JOB (ACCT),'CODDY',CLASS=A,MSGCLASS=X
//CHECK    EXEC PGM=CHKBAL
//CUSTIN   DD DSN=CODDY.CUST.FEB,DISP=SHR
//SYSOUT   DD SYSOUT=*
//POST     EXEC PGM=POSTTXN
//SYSOUT   DD SYSOUT=*
//DAYEND   EXEC PGM=DAYEND
//SYSOUT   DD SYSOUT=*

All lessons in Batch Jobs with JCL