Page 1 of 1

To Get the RC of JCL using REXX

PostPosted: Sun Feb 26, 2012 6:18 pm
by sugavanesh
I am executing a JCL thru REXX, and If the JCL doesnt completes successfully with 'RC=0' it shuld display the message as 'error found' .

Can someone help me out in this please ?

Re: To Get the RC of JCL using REXX

PostPosted: Sun Feb 26, 2012 7:54 pm
by steve-myers
It cannot be done as you seem to think it can be done. First, a Rexx EXEC running in TSO cannot intercept the notify message the system may send to your terminal. Rexx output "trapping" just intercepts messages originated by your TSO session using a very limited mechanism used by properly written TSO functions, not messages sent to your terminal by some foreign process. Second, Rexx is not designed to spin around waiting for a batch process to terminate, possibly minutes, if not hours or days after you have submitted the job.

Re: To Get the RC of JCL using REXX

PostPosted: Mon Feb 27, 2012 1:16 am
by NicC
Why do you need this rather than use the NOTIFY jobcard parameter?

Re: To Get the RC of JCL using REXX

PostPosted: Mon Feb 27, 2012 9:23 am
by steve-myers
NicC wrote:Why do you need this rather than use the NOTIFY jobcard parameter?
That's actually a pretty good question. In the last few months we've seen a number of similar posts, which makes me think someone thinks it's possible to write a job scheduling system using Rexx who has no idea about what Rexx can't do.

Re: To Get the RC of JCL using REXX

PostPosted: Mon Feb 27, 2012 7:04 pm
by MrSpock
The other question I have all the time is, what has the poster already tried? Also, when is it going to sink in that REXX has nothing to do with any of this. Using the standard TSO commands for job processing: SUBMIT, STATUS, and OUTPUT, has met my needs on occasion for many, many years. When they're not sufficient, then I've turned to using batch and/or programming interfaces to whatever spool/output management tool I had to work with: IOF, Sysview, or more recently, SDSF.

It's what, about 20 or so lines of code:

/* REXX */                                                       
Queue "//JOBNAME# JOB (...),'...',"                               
Queue ...                                                         
Queue "$$"                                                       
Call Outtrap(j.)                                                 
"SUBMIT * END($$)"                                               
Call Outtrap(Off)                                                 
/* IKJ56250I JOB JOBNAME#(JOB#####) SUBMITTED */                 
Parse Var j.2 . "JOB " joblist " SUBMITTED" .                     
Do Forever                                                       
  Call Outtrap(j.)                                               
  "STATUS "joblist                                               
  Call Outtrap(Off)                                               
  /* IKJ56197I JOB JOBNAME#(JOB#####) WAITING FOR EXECUTION */   
  /* IKJ56211I JOB JOBNAME#(JOB#####) EXECUTING             */   
  /* IKJ56192I JOB JOBNAME#(JOB#####) ON OUTPUT QUEUE       */   
  Parse Var j.1 . "JOB " joblist status                           
  If status = "ON OUTPUT QUEUE" Then Leave                       
End                                                               
Parse Var joblist jobname "(" jobid ")" .       
outdsn = "OUTPUT."jobname".#'jobid               
"OUTPUT "joblist" PRINT("outdsn")"               
Exit 0