JCL Return Codes and Conditional Execution: How Batch Flow is Controlled
Learn how JCL return codes control step execution using COND, IF/THEN/ELSE, and production-safe patterns.
Return codes are central to mainframe batch control. Every job step ends with a completion code. JCL can use that code to decide whether later steps should run or be skipped.
Common return codes
Typical return codes are:
RC=0: successful completionRC=4: warning or minor issueRC=8: error that usually needs attentionRC=12or higher: serious failure
Site standards vary, but many production jobs treat 0 and sometimes 4 as acceptable.
Why conditional execution matters
Batch jobs often have multiple steps:
1. Sort input data.
2. Run validation.
3. Execute business program.
4. Create report.
5. Send notification.
If validation fails, the business program should not run. Conditional execution prevents bad downstream processing.
IF/THEN/ELSE example
Modern JCL often uses IF statements because they are readable:
//STEP01 EXEC PGM=VALIDATE
//IFGOOD IF (STEP01.RC = 0) THEN
//STEP02 EXEC PGM=PROCESS
//ELSE
//STEPERR EXEC PGM=ERRORRPT
//ENDIF
This reads naturally: if validation succeeds, run processing; otherwise run error reporting.
COND parameter
Older JCL often uses COND. It can be confusing because it describes when to bypass a step.
Example:
//STEP02 EXEC PGM=PROCESS,COND=(0,NE,STEP01)
This means STEP02 is bypassed if STEP01 return code is not equal to 0.
Practical production pattern
A safe pattern is:
- Validate input early.
- Stop or branch if validation fails.
- Display clear messages.
- Avoid hiding failures behind forced return-code changes.
- Document accepted RC values in job comments.
Conclusion
Return codes are the language of batch flow control. A good mainframe developer should understand not only what each RC means, but how later steps respond to it. Clear conditional logic reduces production risk and makes support easier.