What is a Conditional Statement in JCL?
Conditional statements in JCL let your job “decide” which steps to run, based on what happened in previous steps. It’s like telling your JCL: "If the last step failed, do this; otherwise, do that."
This is useful for handling errors or making your job more flexible, without having to run everything every time.
Example:
//STEP1 EXEC PGM=IGYCRCTL //* Compile the program
//STEP2 EXEC PGM=TESTPROG //* Run tests
//IF (STEP1.RC = 0 AND STEP2.RC = 0) THEN
//STEP3 EXEC PGM=COPYOUT //* Copy output
//ELSE
//STEP4 EXEC PGM=PRTERRPT //* Print error report if failed
//ENDIF Explanation:
STEP1: Try to compile program.
STEP2: Run tests.
IF: If both STEP1 and STEP2 ended with a return code (RC) of zero, then do STEP3.
ELSE: If not, then do STEP4.
ENDIF: End the conditional block.
When is this used?
Error Handling: Skip steps if a previous step failed.
Branching Logic: Decide what to do next based on the previous result.
PreviousUnderstanding Instream Procedures, Cataloged Procedures, and Symbolic Parameters in JCLNextJCL Conditional Parameter Types
Last updated
Was this helpful?