Menu
CoddyTech

Return Codes

Part of the Batch Jobs with JCL section of Coddy's COBOL Programming journey. Lesson 9 of 19.

Every step ends with a return code from 0 to 4095, which the log shows as its COND CODE. A COBOL program sets it with the RETURN-CODE special register before STOP RUN:

IF BAD-N > 0
    MOVE 4 TO RETURN-CODE
END-IF.

By long custom the codes mean: 0 all went well, 4 a warning, 8 an error, 12 a severe error, 16 a disaster. A step that finds a few bad records and carries on ends with 4.

The log shows each step's code, and the job ends with the highest one:

IEF142I CHKALL JAN - STEP WAS EXECUTED - COND CODE 0004
IEF142I CHKALL MAR - STEP WAS EXECUTED - COND CODE 0000
$HASP395 CHKALL ENDED - RC=0004

A return code is not an ABEND: the program ended normally and reported how it went. Later steps can test it, which is what the next statements in this chapter do.

challenge icon

Challenge

Easy

Open CHKBAL.cob. Where the comment is, set RETURN-CODE to 4 when BAD-N is more than 0, so step CHECK ends with COND CODE 0004.

Try it yourself

//CHKJOB   JOB (ACCT),'CODDY',CLASS=A,MSGCLASS=X
//CHECK    EXEC PGM=CHKBAL
//CUSTIN   DD DSN=CODDY.CUST.JAN,DISP=SHR
//SYSOUT   DD SYSOUT=*

All lessons in Batch Jobs with JCL