GETMAXCC - find the maximum batch jobstep condition code
Requirements: This program is for a mvs3.8j system; ie: Turkey3.
This code sample shows how a batch job step can search through
all prior job steps to obtain the condition codes returned by the prior
jobsteps.
Its a "how-to" example that you can use in your own code; to make
code logic branched based upon what happened in prior steps in the program rather
that having to reply on messy JCL COND statements.
Personally I decided I needed this functionality to clean up some of my procedures that would "exec pgm=AA,parm=OK" or "exec pgm=AA,parm=NOTOK" (or parm=CCnnn, or COND=EVEN etc) using JCL COND checks... the same program had to be executed but it had to perform different database operations depending on what happened in prior job steps. JCL (at the mvs3.8j level anyway) is not really adequate for logic flow. Moving the checking into that program not only cleaned up the JCL but made that program smaller (no messy parm processing).
Doing google searches on finding the maximum condition code of prior batch jobsteps has a lot of hits, almost all of them using the z/OS SWAREQ macro which does not exist under mvs3.8j. And trying to manually follow the control blocks was a bit of an effort as well. I could not have done it without google, the odd "using" statement that had to use label-16 rather than the normal label was a relevation I would never have managed on my own, so illogical.
Anyway, trying to find out how to do this under mvs3.8j took me literally months. So this assembler code for mvs3.8j example how-to is posted in case anyone else finds it usefull.
Program Source
If you think this may be useful to you this is the latest unstable source code. The latest stable version is in my github repository.
Example job log from my testing
$HASP373 MARKA STARTED - INIT 1 - CLASS A - SYS MID1 IEFACTRT - Stepname Procstep Program Retcode MARKA ASMLKD ASM IFOX00 RC= 0000 MARKA ASMLKD LKED IEWL RC= 0000 MARKA SET08 SETRC RC= 0008 MARKA SET04 SETRC RC= 0004 +ASM IFOX00 00000000 +LKED IEWL 00000000 +SET08 SETRC 00000008 +SET04 SETRC 00000004 +JOB:MARKA MAXCC=00000008 MARKA TESTIT2 GETMAXCC RC= 0000 $HASP395 MARKA ENDED