I am using the following REXX code to get step return codes for a batch job:


/* rexx getrc                        */
/* get the step name and return code */
dump_opt = "N"
parm_opt = "N"
dgts     = "0123456789"
parse arg getrc_opt getrc_opts
do while getrc_opt \= ""
    getrc_opt = translate(getrc_opt)
    if getrc_opt = "DUMP" then
        dump_opt = "Y"
    else
        if getrc_opt = "PARM" then
            parm_opt = "Y"
    parse var getrc_opts getrc_opt getrc_opts
end
numeric digits(32)                   /* ensure max precision */
tcb  = storage(d2x(540),4)           /* psatold in psa */
jscb = storage(d2x(c2d(tcb)+180),4)  /* tcbjscb in tcb */
jct  = storage(d2x(c2d(jscb)+261),3) /* jscbjcta in jscb */
this_step_no = x2d(c2x(storage(d2x(c2d(jscb)+228),1)))
/* this step no. */
fsct = storage(d2x(c2d(jct)+48),3)   /* jctsdkad in jct */
/* is first sct */
temp_sct = fsct
high_rc  = 0
abend    = "N"
say "    Job Step Proc Step Program Rc"
do i = 1 to this_step_no - 1
    jstep   = storage(d2x(c2d(temp_sct)+60),8)
    pstep   = storage(d2x(c2d(temp_sct)+68),8)
    pgmname = storage(d2x(c2d(temp_sct)+124),8)
    rcstep  = x2d(c2x(storage(d2x(c2d(temp_sct)+24),2)))
    sctx    = storage(d2x(c2d(temp_sct)+84),3)
    step_parm = strip(storage(d2x(c2d(sctx)+20),100),"T","00"X)
    /* sctsexec in sct */
    bypass = storage(d2x(c2d(temp_sct)+188),1)
    if dump_opt = "Y" then
        "dydump" storage(d2x(c2d(temp_sct)),512)
    if x2d(c2x(bypass)) = 80 then      /* check if not executed */
        rcstep = 'FLUSHED '
    else
        if x2d(c2x(storage(d2x(c2d(temp_sct)+176),1))) = 4 then do
            abend    = "Y"
            if dump_opt = "Y" then
                "dydump" storage(d2x(c2d(sctx)),256)
            abend_code = x2d(c2x(storage(d2x(c2d(sctx)+130),2)))
            if abend_code >= 4096 then do
                abend_code = left(c2x(storage(d2x(c2d(sctx)+129),2)),3)
                abend_code = " S" || abend_code
              end
            else
                abend_code = "U" || abend_code
            if step_parm = "" then
                rcstep = "ABEND" || abend_code "PARM =" step_parm
            else
                rcstep = "ABEND" || abend_code "PARM =" step_parm
          end
        else
            high_rc = max(high_rc,rcstep)
    if parm_opt = "Y" then
        rcstep = rcstep "      " step_parm
    select
        when jstep = "" & verify(rcstep,dgts) = 0 then
            say right(i,3) pstep copies(" ",8) pgmname mask(rcstep,4)
        when jstep = "" then
            say right(i,3) pstep copies(" ",8) pgmname rcstep
        when verify(rcstep,dgts) = 0 then
            say right(i,3) jstep pstep pgmname mask(rcstep,4)
        otherwise
            say right(i,3) jstep pstep pgmname rcstep
    end
    temp_sct = storage(d2x(c2d(temp_sct)+36),3)
end
if abend = "Y" then
    say "highest rc - ABEND" || abend_code
else
    say "highest rc =" mask(high_rc,4)
return



It works most of the time, but I have one instance where a job gets an RC 08 in 
the first step and is restarted at step 2. If step 2 then gets an RC 08 and the 
job is restarted again at step 2, the REXX code finds that the RC for step 1 is 
013 - even though it did not run.  I have done some testing with restarted jobs 
and cannot recreate it.  Obviously I need to check a different field (in the 
SCT or SCTX?) to see if the job has been restarted and at what step. I have 
looked through the MVS DATA AREAs for SCT and SCTX and do not see anything 
obvious. Can anyone help?

----------------------------------------------------------------------
The information contained in this communication may be confidential, is 
intended only for the use of the recipient(s) named above, and may be protected 
under state or federal law. If the reader of this message is not the intended 
recipient, you are hereby notified that any dissemination, distribution, or 
copying of this communication, or any of its contents, is strictly prohibited. 
If you have received this communication in error, please forward the 
communication to [email protected] immediately and destroy or delete the original 
message and any copy of it from your computer system. If you have any questions 
concerning this message, please contact the sender.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to