JCL · 2026-10-11

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:

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:

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.

← Back to all articles