Many thanks Pedro, I have never worked with mode ADDRESS SDSF before, or hardly and not successfully.
This is a great example to get one going.
I cut it out and changed most things that I could to fit in with my own codepage and standards (# is not a valid char and | is ! in CP 1143).
Here attached it my version of the exec which is passed a JOB(/JES) number "JOBn..." as an argument. It does some basic validation and then traps the output, as I say, all based on your example!
/*REXX*/ TRACE "O"
PARSE ARG jes
re = ", correct it and try again."
PARSE VAR jes 1 job 4 nnn 9 res
IF res<>"" THEN CALL SAYMSG 1,"INVALID JOB NUMBER",,
"Job number" jes "is too long"re
ELSE NOP
IF job<>"JOB" THEN CALL SAYMSG 1,"INVALID JOB NUMBER",,
"Job number" jes "should be of the form JOBnnnnn"re 1
ELSE NOP
IF DATATYPE(nnn,"N")=0 THEN CALL SAYMSG 1,"INVALID JOB NUMBER",,
"Job number" jes "should be of the form JOBnnnnn"re 2
ELSE NOP
IF LENGTH(nnn)<>5 THEN jes = "JOB"RIGHT(nnn,5,0)
ELSE NOP
RC = ISFCALLS("ON")
ADDRESS SDSF
isffilter = 'JOBID EQ 'jes
"ISFEXEC ST"
IF( token.0>0 )THEN CALL GRABJOB
ELSE CALL SAYMSG 0,"NO ROWS FOUND",,
"No rows found in SDSF for JOBID("jes")."
EXIT /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/*===================================================================*/
/* save job output TO a data set */
/*===================================================================*/
GRABJOB:
isfprtddname = "XDC"!!RIGHT('00000'RANDOM(0,99999),5)
isfprtdsname = isfprtddname !! ".LIST"
isfprtdisp = "NEW"
"ISFACT ST TOKEN('"token.1"') PARM(NP XDC)"
IF( SYSDSN(isfprtdsname)="OK" )THEN DO
/*----------------------------------------------------------------*/
/* view the job output data set */
/*----------------------------------------------------------------*/
ADDRESS TSO "ALLOC DD("isfprtddname")",
"DS("isfprtdsname") OLD REUSE"
ADDRESS TSO "EXECIO * DISKR" isfprtddname "(STEM ISF. FINIS "
jn = "?UNKNOWN"
DO i = 11 TO 12
PARSE VAR isf.i . 10 ln 12 ss 14 jn qjw . 3 stm 20 .
IF( ln qjw = "1 JOB" ,
! stm="STMT NO. MESSAGE" )THEN LEAVE
ELSE NOP
END
jj = jn"("jes")"
ADDRESS ISPEXEC "LMINIT DATAID(DATAID) DDNAME("isfprtddname")"
CALL SAYMSG 0,isf.0 "ROWS FOUND",,
isf.0 "rows found in SDSF for job" jj"."
ADDRESS ISPEXEC "VIEW DATAID("dataid")"
ADDRESS ISPEXEC "LMFREE DATAID("dataid")"
ADDRESS TSO "FREE DD("isfprtddname")"
CALL SAYMSG 0,isf.0 "ROWS FOUND",,
isf.0 "rows found in SDSF for job" jj"."
END
ELSE NOP
RETURN /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/*===================================================================*/
/* say a message and exit if code non-zero */
/*===================================================================*/
SAYMSG:
PARSE ARG cc,zerrsm,zerrlm
PARSE VALUE "NONE YES" WITH zerrhm zerralrm
ADDRESS ISPEXEC "SETMSG MSG(ISRZ003)"
IF( cc<>0 )THEN EXIT 1
ELSE RETURN /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
![Very Happy :D](https://www.ibmmainframeforum.com/images/smilies/icon_e_biggrin.gif)