Skip to main content

Introduction

The COND parameter in JCL is used to control the execution of steps based on the return code (RC) from previous steps. This is essential for conditional execution of jobs and avoiding unnecessary steps when a failure or specific condition has already occurred.

You can use COND on:

  • The JOB level: to skip entire steps.
  • The EXEC statement: to control individual step execution.

Common format: COND=(rc,operator[,stepname])

Where:

  • rc is a return code (e.g., 8)
  • operator can be EQ, NE, LT, GT, LE, GE
  • stepname is optional but refers to a previous step

This exercise is designed to help you understand the behavior and usage of the COND parameter through hands-on experimentation. By running a sample JCL and analyzing different scenarios, you will observe how return codes influence the execution of subsequent steps. A small REXX utility will be used to simulate return codes, providing a controlled environment to explore different COND settings.

⚙️ Setup Instructions

Before starting the exercise, set up your environment using the sample JCL and REXX script provided below. This setup will allow you to simulate different return codes in your JCL steps, which you can then use to explore the behavior of the COND parameter.

Setup 1: RETRC-based return code control

Use the following sample JCL to simulate different return codes. This will help create multi-step jobs with varying COND logic.

note

Replace <Your ID> with your training ID and <YOUR REXX EXEC> with the dataset containing the RETRC REXX member.

//<YOUR ID>E  JOB ,NOTIFY=&SYSUID
//COMBINE EXEC PGM=IRXJCL,PARM='RETRC 2'
//SYSEXEC DD DSN=<YOUR REXX EXEC>,DISP=SHR
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*

REXX Program: RETRC
Create in a PDS dataset with RECFM=FB, LRECL=80, BLKSIZE=800 and add below REXX to that dataset.

/* REXX RETURN EXPECTED RC */
PARSE ARG RETCD
SAY RETCD
IF DATATYPE(RETCD) <> 'NUM' THEN RETCD = 0
EXIT RETCD

Setup 2: ABEND simulation using COBOL

To simulate abends such as U4038, use the following COBOL program. This helps test COND=ONLY and COND=EVEN behaviors.

Some installations provide IGYWCLG procedure for compile-link-go. If not use following IGYWCLG, copy it to some proclib and use JCLLIB ORDER=

       CBL SSRANGE
IDENTIFICATION DIVISION.
PROGRAM-ID. U4038PGM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-TABLE.
05 WS-ITEM PIC X(10) OCCURS 5 TIMES.
01 IDX PIC 9(3) VALUE 100.

PROCEDURE DIVISION.
MOVE 'CRASH' TO WS-ITEM(IDX)
DISPLAY 'You should not see this'
GOBACK.

Sample JCL to compile, link, and execute:

//COBCL1  EXEC IGYWCLG,SRC=U4038PGM
//COBOL.SYSIN DD *
<COBOL CODE ABOVE>
/*

Exercise: Fix Invalid JCL

//<YOUR ID>K  JOB ,TYPRUN=HOLD,NOTIFY=&SYSUID                             
//COMBINE EXEC PGM=IRXJCL,PARM='LOOP 100000',COND=(,10)
//SYSEXEC DD DSN=<YOUR REXX EXEC>,DISP=SHR
//SYSTSIN DD DUMMY
//SYSTSPRT DD DSN=&SYSUID..EXERCISE.OUTPUTB,
// DISP=(MOD,CATLG),SPACE=(CYL,(2,2)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)

Exercise: Basic COND Usage

Objective: Observe how the COND parameter skips steps based on a return code.

Instructions: Create a job with two steps:

  • STEP1: Return RC = 0
  • STEP2: Should be skipped if STEP1 returns RC = 0

Exercise: Testing GT Condition

Objective: Test execution flow using the GT operator in COND.

Instructions: Create a job with two steps:

  • STEP1: Return RC = 4
  • STEP2: Should only run if STEP1 RC is less than or equal to 4

Exercise: Multi-Step Dependency with Mixed COND

Objective: Create a chain of steps where each depends on a condition from a prior step.

Instructions:

  • STEP1: Return RC = 8
  • STEP2: Return RC = 4 (run only if STEP1 RC ≠ 8)
  • STEP3: Return RC = 0 (skip if STEP2 RC = 4)
  • STEP4: Return RC = 16 (run only if STEP3 did not run)

Exercise: Conditional Maze

Objective: Practice building complex dependency logic across multiple steps.

Instructions: Create a Job with 5 Steps each with the following specification:

  • STEP1
    • RC = 8
  • STEP2
    • RC = 6
    • Run only if STEP1 RC = 6
  • STEP3
    • RC = 4
    • Run only if STEP2 RC = 8
  • STEP4
    • RC = 2
    • Run only if STEP1 RC = 8
  • STEP5
    • RC = 16
    • Run only if STEP4 RC is between 4 and 8

Exercise: Skip Step Based on Any Previous Failure

Objective: Skip execution if any previous step fails (e.g., RC ≥ 8).

Instructions:

  • STEP1: Return RC = 0
  • STEP2: Return RC = 8
  • STEP3: Should be skipped if any previous step returns RC ≥ 8

Exercise: Multiple Conditions in COND

Objective: Use more than one condition in a single COND parameter.

Instructions:

  • STEP1: RC = 0
  • STEP2: RC = 12
  • STEP3: Run only if:
    • STEP1 RC ≠ 0 AND
    • STEP2 RC ≠ 12

Exercise: Conditional OR

Objective: Run a step only if either of two prior steps return RC > 0.

Instructions:

  • STEP1: RC = 4
  • STEP2: RC = 0
  • STEP3: Run if either STEP1 or STEP2 have RC > 0

Exercise: Always Run Final Step

Objective: Ensure a final cleanup or notification step always runs, even if earlier steps fail.

Instructions:

  • STEP1: RC = 12
  • STEP2: RC = 8
  • STEP3: Skip if STEP2 RC ≥ 8
  • STEP4: Always run regardless of STEP1–3 results

Exercise: Chained Execution

Objective: Make execution of each step depend on the success of the previous one.

Instructions:

  • Create 5 steps:
    • Each step should run only if the previous step returns RC = 0
  • Modify STEP3 to return RC = 4 and observe the chain break.

Exercise: Abend Testing

Create a job with the following steps:

  • STEP1 calls a program that will abend (our U4038PGM created in setup)
  • STEP2 should execute only if STEP1 fails

Create a job with the following steps:

  • STEP1 fails due to an abend (our U4038PGM created in setup)
  • STEP2 should execute regardless of abend or not

Create a job with the following steps:

  • STEP1 fails due to an abend (our SOC4PGM created in setup)
  • STEP2 should not execute
  • STEP3 should execute only if STEP1 abend
  • STEP3 should execute regardless of abend or not

Summary

What is COND? The COND parameter is used to bypass (skip) a step based on the return code (RC) of previous steps. If the COND condition evaluates to true, the step is skipped.

Think of it as: 👉 “Skip this step if...”

Tips to Remember

  • COND evaluates to true → step is skipped
  • Use COND=(rc,operator) to check return codes from any previous step.
  • Use COND=(rc,operator,stepname) to check a specific step’s RC.
  • COND=ONLY → run only if any previous step abend.
  • COND=EVEN → run even if a previous step success or abend.
  • Keep logic simple — too many conditions can be confusing and error-prone.