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
- 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.
- 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.
- 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.
- Name the step you mean. If you name a step and it did not run, the expression is false.
- 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
// ENDIFKit's JCL checker finds no mistakes and reads the condition as: Runs the following steps only if (STEP1.RC <= 8).
Related: Job log reader · S806 module not found · S0C7 data exception · JCL errors explained (Mainframe Path)
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/