Learn it on Mainframe Path. Do it with Mainframe KIT.Learn on Mainframe Path ▸
Mainframe KIT ● Nothing leaves this tab

JCL return codes: what do 0, 4, 8, 12 and 16 mean?

Each program sets its own return code. JCL can test it.

Checked against IBM documentation

THE SHORT ANSWER

A step ends with a return code that the program chooses, so what a number means depends on the program. IBM defines 0, 4, 8, 12 and 16 for Access Method Services (IDCAMS): 0 ran as expected, 4 a warning, 8 a requested function completed with major specifications bypassed, 12 the function could not be performed, 16 a severe error. In JCL you test the code with IF/THEN/ELSE/ENDIF.

Steps

  1. Find the step's return code. Look in the job log, or paste the log into the job log reader, which lists every condition code it finds.
  2. Read it against that program's documentation. The same number can mean different things in different programs. The IDCAMS meanings are on the IBM page below.
  3. Test it in JCL. Code IF followed by a relational expression such as (STEP1.RC <= 8), then THEN, the steps to run, and ENDIF. IBM's own example tests RC > 4.
  4. Name the step you mean. If you name a step and it did not run, the expression is false.
  5. Do not hide a failure. Decide on purpose which return codes your job accepts; the example below accepts 8 because deleting a data set that is not there ends with 8.

Worked example: run step 2 only if step 1 ended with 8 or less

STEP1 deletes a data set that may not exist. IBM lists "an entry to be deleted ... could not be found in the catalog" as a case of return code 8, so the job accepts 8:

//RCDEMO   JOB (ACCT),'RC DEMO',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  DELETE MY.TEST.DATA
/*
//         IF (STEP1.RC <= 8) THEN
//STEP2    EXEC PGM=IEFBR14
//NEWDS    DD DSN=MY.TEST.DATA,DISP=(NEW,CATLG),
//            SPACE=(TRK,(1,1)),RECFM=FB,LRECL=80
//         ENDIF

Kit's JCL checker finds no mistakes and reads the condition as: Runs the following steps only if (STEP1.RC <= 8).

Sources, checked : IF/THEN/ELSE/ENDIF statement construct, z/OS 3.2.0 MVS JCL Reference; Relational-expression field, z/OS 3.2.0 MVS JCL Reference; Condition Codes, z/OS 3.2.0 Access Method Services Commands. Explanations are in our own words; the worked example is invented. Confirm against IBM documentation before changing production systems. mainframekit.com/guides/jcl-return-codes/

Use your browser's Print command for a one-page copy.