In this blog, we have already discussed how to submit a JCL(skeleton) from REXX. In this post, we will see how to capture the job data and analyze them.
Step1: Submit the job
CALL JCL_SUBMIT
Step2: Read the job status until it is done
CALL JCL_STATUS
Step3: Once Job is done, read its data.
CALL SPOOL_ACCESS
Incase of questions, please write in comments.
Code is given below. Please read instructions given below and make changes accordingly.
JCL_Submit:
TEMP_FILE="'"Your Temporary PS file"'"
SKL_MEM = MEMBER_NAME --> Your skeleton JCL member name
"ALLOC FI(ISPFILE) DA("TEMP_FILE") SHR"
"ISPEXEC LIBDEF ISPSLIB DATASET ID('Your Skeleton PDS')"
"ISPEXEC FTOPEN "
"ISPEXEC FTINCL "SKL_MEM" "
"ISPEXEC FTCLOSE "
"ISPEXEC VGET (ISPFILE)"
X=OUTTRAP("SUB.")
ADDRESS TSO "SUBMIT "TEMP_FILE" "
X=OUTTRAP("OFF")
"FREE FI(ISPFILE)"
RETURN
JCL_Status:
DO K = 1 TO SUB.0
PARSE VAR SUB.K 'JOB' JOBNAME '(' JOBID ')' STATUS
END K
SAY "Your JobName Is "JOBNAME" JobID Is "JOBID
JOBDONE = 'NO'
SUBJOBNAME = STRIP(JOBNAME,B)
SUBJOBID = STRIP(JOBID,B)
SUBJOB = SUBJOBNAME !! "(" !! SUBJOBID !! ")"
DO UNTIL JOBDONE = 'YES'
X=OUTTRAP("OUT.")
ADDRESS TSO "STATUS" SUBJOB
X=OUTTRAP("OFF")
DO K = 1 TO OUT.0
PARSE VAR OUT.K 'JOB ' JOBNAME '(' JOBID ')' STATUS
STATUS = STRIP(STATUS)
SAY " Please wait .... Your Job Status is" STATUS
IF POS('ON OUTPUT QUEUE',STATUS) > 0 THEN DO
JOBDONE = 'YES'
CALL RETURN_CODE
END
ELSE DO
CALL MYWAIT 20
END
END K
END
MYWAIT:
ARG SECS
TIMEDIFF = 0
STARTTIME = TIME('S')
DO UNTIL TIMEDIFF >= SECS
TIMEDIFF = TIME('S') - STARTTIME
END
RETURN
RETURN_CODE:
RC=ISFCALLS("ON")
ADDRESS SDSF "ISFEXEC ST"
ISFCOLS= "JNAME JOBID RETCODE"
COLDTL=WORD(ISFCOLS,1)
DO IX=1 TO ISFROWS
DO JX=1 TO WORDS(ISFCOLS)
COL=WORD(ISFCOLS,JX)
END
IF JOBID.IX = SUBJOBID THEN DO
SAY "Your Job Return Code is " RETCODE.IX
RETCODE=RETCODE.IX
END
END
RC=ISFCALLS("OFF")
RETURN
RC=ISFCALLS('ON')
ADDRESS SDSF "ISFEXEC ST"
DO IX=1 TO JOBID.0
IF JOBID.IX = SUBJOBID THEN DO
PX = IX
ADDRESS SDSF "ISFACT ST TOKEN('"TOKEN.IX"') PARM(NP ?)" ,
"( PREFIX JDS_"
DO JX=1 TO JDS_DDNAME.0
IF JDS_DDNAME.JX="Your DDNAME" THEN DO
STEP=STRIP(JDS_STEPN.JX)
IF STEP="Your Step Name" THEN DO
ADDRESS SDSF "ISFACT ST TOKEN('"JDS_TOKEN.JX"') PARM(NP SA)"
DO KX = 1 TO ISFDDNAME.0
"EXECIO * DISKR" ISFDDNAME.KX "(STEM LINE. FINIS"
ELEMENT.0 = 0
DO LX = 1 TO LINE.0 ---- Your Logic --------
END
END
END
END
END
END
END
RC=ISFCALLS('OFF')
RETURN
No comments:
Post a Comment