JCL IF statement
JCL statements that run or skip job steps depending on how earlier steps ended, written as IF, THEN, ELSE and ENDIF.
Also written IF/THEN/ELSE, IF THEN ELSE ENDIF, ENDIF, conditional step
The JCL IF statement lets a job decide which steps to run based on what happened earlier. You write a condition, the steps to run if it is true, and optionally the steps to run if it is false.
A simple example: // IF (STEP1.RC = 0) THEN, then the steps to run when STEP1 ended with return code 0, then // ELSE, then the steps for any other result, then // ENDIF. You can test return codes with RC, whether a step abended with ABEND, a specific abend code with ABENDCC, and whether a step ran at all with RUN. Conditions can be combined with AND and OR.
IF does the same job as the older COND parameter but is easier to read. COND says when to skip a step, which works the opposite way to how most people think. IF says when to run it.
Both are still common, so you need to read both. For new JCL, many sites prefer IF.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- COND parameterThe older way of telling a job step whether to run, based on the return codes of earlier steps.
- 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.
- AbendAn abnormal end: a program stopping in an uncontrolled way rather than finishing and reporting a result.