JCL Condition Codes

Here is some trivial knowledge you may use to impress, (or bore), casual acquaintances at your next cocktail party. And who knows? Should you ever find yourself kidnapped and forced, at gunpoint, to get a “Job” to run on an old IBM mainframe, it may save your life!

In the IBM mainframe world, the term “Job” is used to refer to a batch process that executes one or more programs sequentially. These jobs are written in something called JCL, which stands for Job Control Language.

Often, when a job executes more than one program, you want the job to stop processing if something didn’t work correctly in a prior program, or skip processing one or more programs for some reason. This is done through the use of condition codes.

Here is an example: //STEP15 EXEC PGM=PROGRAM1,COND=(0,LE)

Now what do you suppose the underlined portion of this JCL statement means? Well, quite simply, it means NEVER EXECUTE THIS PROGRAM!

Huh?

Well, unfortunately, the geniuses behind the development of the JCL language were extreme propeller-hat weenies. (For example, when determining the length of a key in a VSAM file, they came up with the brilliant idea to start counting at zero, because the first position would start at OFFSET ZERO. Obvious, huh?) The condition code above roughly translates as, “bypass this step if zero is less than or equal to the condition code of any prior step.” So, unless STEP15 is the very first step in the job, (because then there is no prior condition code), PROGRAM1 will never be executed, because Condition Codes are never negative.

A more typical Condition Code is this: COND=(04,LT). This means bypass executing this program if 4 is less than the condition code of any prior step. It is common practice for a program to set a return code of 8 or higher if something is not quite right during its processing, and this needs to be brought to someone’s attention.

Of course, what is called an ABEND will bring down the job anyway. An ABEND is basically any instruction that for some reason the computer can’t understand, such as a divide by zero, or an instruction to perform arithmetic on a numeric field that doesn’t contain valid numeric data. But abends should be avoided, because the job comes to an abnormal end and just stops processing. This is when your lowly on-call programmer, (such as me!), gets that dreaded 2:00 am phone call, because at that point human intervention is required.

Fascinating stuff, huh?