OS expects programs to set a return code which specifies how successful the program thought it was. The most common conventional values are:
- 0 = all OK
- 4 = minor errors or problems
- 8 = significant errors or problems
- 12 = major errors or problems, the results (e.g. files or reports produced) should not be trusted.
- 16 = very serious problems, do not use the results!
OS JCL refers to the return code as COND (“condition code”), and can use it to decide whether to run subsequent steps. However, unlike most modern programming languages, conditional steps in OS JCL are not executed if the specified condition is true—thus giving rise to the mnemonic, “If it’s true, pass on through [without running the code].” To complicate matters further, the condition can only be specified after the step to which it refers. For example:
//MYJOB JOB ………..
//STEP01 EXEC PGM=PROG01
//STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01)
//STEP03 EXEC PGM=PROG03,COND=(8,LE)
//STEP04 EXEC PGM=PROG04,COND=(ONLY,STEP01)
//STEP05 EXEC PGM=PROG05,COND=(EVEN,STEP03)
- Run STEP01, and collect its return code.
- Run STEP02 unless the number 4 is greater than STEP01’s return code.
- Run STEP03 unless the number 8 is less than or equal to any previous return code.
- Run STEP04 only if STEP01 abnormally ended.
- Run STEP05, even if STEP03 abnormally ended.
This translates to the following pseudocode:
if STEP01’s return code is greater than 4 then
if any previous return code is less than or equal to 8 then
if STEP01 abnormally ended then
if STEP03 abnormally ended then
You may also like to look at: