View previous topic :: View next topic
|
Author |
Message |
muralialla
New User
Joined: 03 Jan 2007 Posts: 11 Location: Chennai
|
|
|
|
Hi All,
My purpose is to submit a job and verify the completion status. I will get the job JCL and DSN from console. i am issuing
"SUBMIT ('"TEMPDSN"("TEMPJOB")'"
After submiting this how to get the job id and job name to get the status? |
|
Back to top |
|
|
avaneendra_linga
New User
Joined: 13 Dec 2006 Posts: 73 Location: Hyderabad
|
|
|
|
hi,
this way u can get the job id and job name and status..
X=OUTTRAP("SUB.")
ADDRESS TSO "SUBMIT '"JCLDSN"("JCLMEM")'"
X=OUTTRAP("OFF")
DO K = 1 TO SUB.0
PARSE VAR SUB.K 'JOB' JOBNAME '(' JOBID ')' STATUS
END K
for seeing job status: continue...
JOBDONE = 'NO'
DO UNTIL JOBDONE = 'YES'
/*SAY 'OUTPUT FROM STATUS CMD...' */
X=OUTTRAP("OUT.")
ADDRESS TSO "STATUS" SUBJOB
X=OUTTRAP("OFF")
DO K = 1 TO OUT.0
/*SAY OUT.K */
PARSE VAR OUT.K 'JOB ' JOBNAME '(' JOBID ')' STATUS
STATUS = STRIP(STATUS)
IF POS('ON OUTPUT QUEUE',STATUS) > 0 THEN JOBDONE = 'YES'
ELSE DO
/*ADDRESS ATTCHMVS "WAIT 00000100" */ /* FORMAT HHMMSSMM */
CALL MYWAIT 10
END
END K
END
sleep function:
MYWAIT:
ARG TSEC
TIMEDIFF = 0
STARTTIME = TIME('S')
DO UNTIL TIMEDIFF >= TSEC
TIMEDIFF = TIME('S') - STARTTIME
END
RETURN |
|
Back to top |
|
|
avaneendra_linga
New User
Joined: 13 Dec 2006 Posts: 73 Location: Hyderabad
|
|
|
|
in the above code..subjob parameter is..
SUBJOBNAME = STRIP(JOBNAME,B)
SUBJOBID = STRIP(JOBID,B)
SUBJOB = SUBJOBNAME || "(" || SUBJOBID || ")"
let me know if it works.... |
|
Back to top |
|
|
muralialla
New User
Joined: 03 Jan 2007 Posts: 11 Location: Chennai
|
|
|
|
Hi Avaneendra,
I am able to get the job id and job name correctly. But whle getting the status of the job i am going to infinet loop with your code. It is not coming out of the while loop after the job completion. I think its not catching the return code properly.
Look at the code....
X=OUTTRAP("SUB.")
ADDRESS TSO "SUBMIT ('"TEMPDSN"("TEMPJOB")'"
X=OUTTRAP("OFF")
DO K = 1 TO SUB.0
PARSE VAR SUB.K 'JOB' JOBNAME '(' JOBID ')' STATUS
END K
SAY JOBNAME
SAY JOBID
JOBDONE = 'NO'
SUBJOBNAME = STRIP(JOBNAME,B)
SUBJOBID = STRIP(JOBID,B)
SUBJOB = SUBJOBNAME || "(" || SUBJOBID || ")"
SAY SUBJOB
DO UNTIL JOBDONE = 'YES'
SAY JOBDONE
/*SAY 'OUTPUT FROM STATUS CMD...' */
X=OUTTRAP("OUT.")
ADDRESS TSO "STATUS" SUBJOB
X=OUTTRAP("OFF")
DO K = 1 TO OUT.0
/*SAY OUT.K */
PARSE VAR OUT.K 'JOB ' JOBNAME '(' JOBID ')' STATUS
STATUS = STRIP(STATUS)
IF POS('ON OUTPUT QUEUE',STATUS) > 0 THEN JOBDONE = 'YES'
ELSE DO
/*ADDRESS ATTCHMVS "WAIT 00000100" */ /* FORMAT HHMMSSMM */
CALL MYWAIT 10
END
END K
END
EXIT
/*SUBROUTINE FOR WAITING*/
MYWAIT:
ARG SECS
SAY 'MYWAIT'
TIMEDIFF = 0
STARTTIME = TIME('S')
DO UNTIL TIMEDIFF >= SECS
TIMEDIFF = TIME('S') - STARTTIME
END
RETURN
Any suggestions please?
Thanks for your reply |
|
Back to top |
|
|
muralialla
New User
Joined: 03 Jan 2007 Posts: 11 Location: Chennai
|
|
|
|
Hi Avaneendra,
I found the problem. My job is going to SAR after executing so the program is not able to find it in spool. I have changed the message class of the job to stay in the spool after execution. Now the problem is with the Abended job, i want to get the return code like 'U4095'..etc...
How to get that? |
|
Back to top |
|
|
avaneendra_linga
New User
Joined: 13 Dec 2006 Posts: 73 Location: Hyderabad
|
|
|
|
If you use SDSF I have a REXX that my be helpful:
/* REXX */
/* Receive MAXRC out of SDSF
Parameter:
jobname - JobName of the submitted job
jobid - JobID of the submitted job
*/
arg jobname jobid
address TSO
if(jobname = "")
then do
return "XXMAXRC> JobId empty"
end
if(jobid = "")
then do
return "XXMAXRC> JobId empty"
end
maxrc = ""
/* write SDSF Commands to QUEUE */
queue "SET CONFIRM OFF"
queue "OWNER *"
queue "PREFIX *"
queue "H"
queue "SELECT "jobname jobid
queue "AFD REFRESH"
queue "FIND "jobname
queue "END"
queue ""
/* allocate in-/out-dataset */
"alloc dd(isfin) new reuse unit(vioda)",
"recfm(f,b) lrecl(80) blksize(27920) space(1) tracks"
"alloc dd(isfout) new reuse unit(vioda)",
"recfm(f,b,a) lrecl(301) blksize(27993) space(1) cyl"
/* write input-dataset from QUEUE */
"execio * diskw isfin (finis"
/* SDSF-Call */
PARM = "/ ++20,400"
address LINKPGM "SDSF PARM"
/* read isfout in out. */
"execio * diskr isfout (stem out. finis"
"free dd(isfin,isfout)"
do i=1 to out.0 by 1
if(pos(jobname,out.i) ^= 0 & pos(jobid,out.i) ^= 0)
then do
maxrc = substr(out.i,276)
leave
end
end
/* */
/* Alter ReturnCodes */
/* */
if(maxrc = "")
then do
maxrc = "XXMAXRC> JobId empty"
end
else do
/* Returncode = 'CC 0000' ===> 'R0000' */
if(left(maxrc,2) = "CC")
then maxrc = "R"!!SUBSTR(maxrc,4,4)
/* Returncode = 'ABENDU3501' ===> 'U3501' */
if(left(maxrc,6) = "ABENDU")
then maxrc = "U"!!SUBSTR(maxrc,7,4)
/* Returncode = 'ABEND S0C7' ===> 'S0C7 ' */
if(left(maxrc,7) = "ABEND S")
then maxrc = SUBSTR(maxrc,7,4)
/* other RCs (=HighRC) ===> 'X'RC */
/* z.B. */
/* Returncode = 'CANCEL' ===> 'XCANCEL' */
/* Returncode = 'JCL ERROR' ===> 'XJCL ERROR' */
if(left(maxrc,1) ^= "R" & left(maxrc,1) ^= "U" & left(maxrc,1) ^= "S")
then maxrc = 'X'!!maxrc
end
return maxrc
there might be small corrections in this....i hope it works fine.... |
|
Back to top |
|
|
muralialla
New User
Joined: 03 Jan 2007 Posts: 11 Location: Chennai
|
|
|
|
Thanks Avaneendra...
Its working...
meanwhile i did almost similar code.
1. I copied all the job log to a PDS.
2. I searched for the return code.
Thanks a Ton!!!!! |
|
Back to top |
|
|
|