COND parameter
Tells a step to be skipped when an earlier step ended with a code you name.
Also written COND, conditional execution
Why it matters. If step 1 fails, you do not want step 2 to run on bad data. COND stops it.
See it
Skip this step if 4 is less than the return code of STEP010.
Syntax
//stepname EXEC PGM=name,COND=(code,operator[,stepname]) //stepname EXEC PGM=name,COND=EVEN //stepname EXEC PGM=name,COND=ONLY
- code
- The number to compare with.
- operator
- GT, GE, EQ, LT, LE or NE. The test is: code operator earlier-return-code.
- stepname
- Test only that step. Without it, every earlier step is tested.
- EVEN
- Run even if an earlier step abended.
- ONLY
- Run only if an earlier step abended.
Try it COND
- 1
You're editing job NIGHTRUN. Write the EXEC statement of STEP2: run the program IEFBR14, and skip the step if 4 is less than the return code of an earlier step.
JCL //STEP2 EXEC PGM=IEFBR14,COND=(4,LT) - 2
Submit the job NIGHTRUN from your DEV JCL library.
SUBMIT 'ZB0001.DEV.JCL(NIGHTRUN)' - 3
Read the step messages, JESYSMSG. See which steps ran.
OUTPUT NIGHTRUN JESYSMSG
Remember
- COND=(code,operator) says when to SKIP the step.
- COND=(4,LT) skips the step if 4 is less than an earlier return code.
- A step with no COND runs, unless an earlier step abended. After an abend the rest of the job is skipped, except steps with COND=EVEN or COND=ONLY.
The usual mistake
Reading COND=(4,LT) as "run this step if the code is less than 4"
COND is the reason to skip, not the reason to run. A code of 8 makes the test true, so the step is skipped.
Read it as: skip if 4 is less than the earlier code
On real z/OS
COND works as on z/OS in MF/OS. A COND on the JOB statement is allowed on z/OS too, and the system skips the rest of the job as soon as one test is true. New jobs mostly use IF / THEN / ELSE / ENDIF, where the test reads the way you say it: IF RC > 4.
Where can I practise COND parameter?
Right here, at ZedBank. You take a junior job at a simulated bank and use COND parameter in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- Return codeA number a program leaves behind saying how it went. Zero for clean, higher numbers for warnings and failures.
- Job stepOne program execution within a job. A job is simply a sequence of steps that run in order.
- JCLJob Control Language: the language used to tell the mainframe what programs to run, in what order, and with what files.
- EXEC statementThe JCL statement that starts a step by naming the program or procedure to run.