Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to get the Job id and Jobname using REXX?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
muralialla

New User


Joined: 03 Jan 2007
Posts: 11
Location: Chennai

PostPosted: Tue Jan 09, 2007 11:07 am    Post subject: How to get the Job id and Jobname using REXX?
Reply with quote

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
View user's profile Send private message

avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Tue Jan 09, 2007 11:42 am    Post subject: Re: How to get the Job id and Jobname using REXX?
Reply with quote

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
View user's profile Send private message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Tue Jan 09, 2007 11:44 am    Post subject: Re: How to get the Job id and Jobname using REXX?
Reply with quote

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
View user's profile Send private message
muralialla

New User


Joined: 03 Jan 2007
Posts: 11
Location: Chennai

PostPosted: Tue Jan 09, 2007 12:47 pm    Post subject: Re: How to get the Job id and Jobname using REXX?
Reply with quote

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
View user's profile Send private message
muralialla

New User


Joined: 03 Jan 2007
Posts: 11
Location: Chennai

PostPosted: Tue Jan 09, 2007 1:17 pm    Post subject: Re: How to get the Job id and Jobname using REXX?
Reply with quote

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
View user's profile Send private message
avaneendra_linga

New User


Joined: 13 Dec 2006
Posts: 73
Location: Hyderabad

PostPosted: Tue Jan 09, 2007 4:53 pm    Post subject:
Reply with quote

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
View user's profile Send private message
muralialla

New User


Joined: 03 Jan 2007
Posts: 11
Location: Chennai

PostPosted: Tue Jan 09, 2007 6:03 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Running an REXX EXEC implicitly sho7hills CLIST & REXX 3 Thu Apr 20, 2017 8:14 am
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us