MainframeSupports
tip week 42/2005:

Recently I needed a job where I wrote the SYSOUT output to a dataset instead of the JES spool file. At the same time I wanted to write the contens of the dataset to a JES spool file. The dataset contens I used as input to a later jobstep. To make such a job work properly gave me a lot of challenges.

The primary task was to ensure that the SYSOUT output always was written to a JES spool file as it would have been originally, if I didn't route it to a dataset instead. I had to make a step that always ran when the previous step was executed. I will refer to such a step as step ALWAYS. If you are a little familiar with JES, you will now tell me to use COND=EVEN in step ALWAYS . And so I did. At the same time I love to use COND=(4,LT) in the JOB card, and in this case step ALWAYS only gets executed if one of the previous steps abends or if all the previous steps ends with a COND CODE of four or less, but not if the COND CODE is greater than four.

"Silly fool, remove COND=(4,LT) from the job card and add COND=(4,LT) to each job step instead". And so I did, too. And now step ALWAYS gets executed ALWAYS, even if the previous step didn't get executed. But I only wanted to execute step ALWAYS when the previous step was executed or abended. So COND=EVEN wasn't the miracle cure, because it will be executed if any of the previous steps abends and not just the previous one.

This made me think a lot. One of the reasons is that COND=EVEN doesn't allow you to refer to one particular previous step. Finally I found the solution using IF and ENDIF DD cards. Here is an example:

//STEP0001 EXEC PGM=STUPID,COND=(4,LT)
//*
//PREVIOUS EXEC PGM=PREVIOUS,COND=(4,LT)
//*
// IF (PREVIOUS.RUN ! PREVIOUS.ABEND) THEN
//ALWAYS   EXEC PGM=IEFBR14
// ENDIF

This job will always execute step ALWAYS if step PREVIOUS has been executed. If step STEP0001 abends or ends with a COND CODE greater than four none of the following steps gets executed. Now I have acheived what I wanted from the beginning. Please note that the condition PREVIOUS.RUN is false if PREVIOUS abends. In my opinion step PREVIOUS has been executed if it abends, but JES2 has a different opinion. And a last remark: Do not use any COND in the job card, because it will ruin my example.

Previous tip in english        Sidste danske tip        Tip list