One of the biggest mysteries in JCL is the ways the COND parameter works. Very few people understand how it works. I do not belong to this group, but I get along using some basic rules. Recently I got involved in a COND problem which made me curious and I ended up being somewhat wiser. I will now try to pave the way into a better understanding of the COND parameter and the way it works.
I almost always use COND=(4,LT) on the JOB card. After each step in the job the return code (RC) of the step is compared to the COND parameter in the JOB card. If RC<=4 the following step is allowed to execute. The correct translation of COND=(4,LT) is 4<RC which is the same as RC>4 meaning the exact opposite of RC<=4. Funny enough the COND parameter tells JES when to skip a step, not when to execute it. What does COND=(0,NE) mean? It means 0<>RC or RC<>0 which again means that a step is only executed if RC=0 in the previous step. The basic rule of interpreting the COND parameter is thus:
Now you have the condition for when a step ruled by a COND parameter is executed. The COND parameter on the job card is evaluated after each step. If it is fulfilled the job terminates immediately even though a COND parameter of a following step indicates that it should have been executed.
How about the evaulation of the COND parameter on the EXEC card? On the first step the COND parameter is ignored because there is no previous step. On the second step the COND parameter is evaulated using the RC of the first step, but what about the remaining steps? In the remaining steps the COND parameter is evaluated using the RC values of all the previous executed steps. If the COND parameter is fulfilled for one of those RC values the step is skipped.
Now imagine using COND=(4,NE) (meaning RC<>4). If just one of the previous step terminates with a RC not equal to four the step is not executed. Fortunately you are able to specify the COND parameter as COND=(value,operator,stepname) on the EXEC card and in this case value and operator is only compared to RC from stepname.
Last but not least I will give you a good trick to try out your COND parameter processing in a job:
IDCAMS is able to return exactly the return code you want. The two steps above will always be executed if they are the two first steps in a job having no COND parameter on the JOB card. It is very easy to change MAXCC in STEP0001 and immediately see the impact on STEP0002 which no longer will be executed.