So, I found that it is actually tricky to get the current jobid using REXX
in a WLM-initiated environment.
Here's a slightly patched REXX script that I found by Bill Lalonde that
will do it:

/* REXX */
/* curjobid.rexx
   (adapted from http://billlalonde.tripod.com/rexx/findjsab.txt) */
/* Based on expansion of IAZXJSAB macro */
/* This EXEC returns current jobname, jobid, userid and */
/*   name of the component which created the JSAB       */
/*   for the current task / address space               */
NUMERIC DIGITS 10
tcb   = C2D(STORAGE(21C,4))    /*  get current TCB */
jsab  = 0                      /*  null pointer    */
if tcb \= 0 then do
    stcb  = C2D(STORAGE(D2X(tcb+312),4))
    jsab  = C2D(STORAGE(D2X(stcb+188),4))
    end
if jsab = 0 then do
    ascb  = C2D(STORAGE(224,4))    /*  get current TCB */
    assb  = C2D(STORAGE(D2X(ascb+336),4))
    if ascb = 0 then do
        call lineout stderr,'Unable to locate JSAB from ASCB at 'D2X(ascb)
        exit 8
        end
    jsab  = C2D(STORAGE(D2X(assb+168),4))
    if jsab = 0 then do
        call lineout stderr,'Unable to locate JSAB from ASCB at 'D2X(ascb)
        exit 8
        end
    end
flg1  = C2D(STORAGE(D2X(jsab+13),1))
DO WHILE flg1 > 127
   eye   = STORAGE(D2X(jsab),4)
   If eye \= 'JSAB' then do
        call lineout stderr,'Invalid JSAB found at 'D2X(jsab)
        exit 8
        end
   jsab  = C2D(STORAGE(D2X(jsab+4),4))
    if jsab = 0 then do
        call lineout stderr,'Unable to locate a valid JSAB'
        exit 8
        end
   flg1  = C2D(STORAGE(D2X(jsab+13),1))
   END
/* jbnm  = STORAGE(D2X(jsab+28),8) */
jbid  = STORAGE(D2X(jsab+20),8)
/* comp  = STORAGE(D2X(jsab+16),4) */
/* usid  = STORAGE(D2X(jsab+44),8) */
say jbid
exit 0

So, then you can add this step to your job to copy a previous step's spool
file to another DD:

// EXEC PGM=COZBATCH
//STDIN DD *
fromdsn //-jes.$(curjobid.rexx).stepname.procstep.ddname |
   todsn //DD:OUT
//OUT   DD ...
//

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN

Reply via email to