Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to trap return code of a job in rexx program

Status
Not open for further replies.

gpinaki

Programmer
Aug 7, 2002
5
0
0
IN
Hi,
I have a rexx program that submits a Jcl. After completion it throws a panel with outputs. Now I want to trap the return code of that job in my rexx program and wants to show in the output panel .Please tell me how to trap that return code.
 
where is your log? IOF, SDSF, LDMS?

with all of them you can deal with rexx but you have to look at teh right manual.

Heinz
 
Hi KarlheinzWittemann ,


I have the same problem & I have log in SDSF ..so can u please tell me which manual to look for ?

Thanks in advance,
RAkesh
 
In the REXX program use the OUTTRAP facility to trap the error complete message along with the return code. I don't know if this will work out or not but try it once.

Thanks
Rajesh Vemuri
 
I'm not sure outtrap would work here...
try using sdsf in
REXX
 
I think there is a rather brutal way of doing this on the mainframe. You need to do the following;

1) sumbit the job and trap the jobname and number
2) put the REXX into a loop, turn on an output trap and issue the TSO command &quot;STATUS <jobname>(JOB<number>)&quot;
3) check the resulting IKJnnnnnI message until you get an indication the job is complete (note: these messages may be enough)
4) turn on another trap and issue the &quot;OUT <jobname>(JOB<number>) KEEP&quot; (note: not sure of this syntax) which will put the contents of the output to your trap

I suggest you look up STATUS, OUT, and maybe IKJ5619* through help or QuickRef.

Of course if your site are using a spool writer you are either totally stuffed or you have to work out an interface to it...
 
If you use SDSF I have a REXX that my be helpful:

Run this script in a loop until
return ^= &quot;XXMAXRC> JobId empty&quot;


Code:
/* 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 = &quot;&quot;)                            
then do                                     
  return &quot;XXMAXRC> JobId empty&quot;   
end                                         
if(jobid = &quot;&quot;)                              
then do                                     
  return &quot;XXMAXRC> JobId empty&quot;   
end                                         

maxrc = &quot;&quot;                                  


/* write SDSF Commands to QUEUE */    
queue &quot;SET CONFIRM OFF&quot;                  
queue &quot;OWNER *&quot;                                               
queue &quot;PREFIX *&quot;                                              
queue &quot;H&quot;                                                     
queue &quot;SELECT &quot;jobname jobid                                  
queue &quot;AFD REFRESH&quot;                                           
queue &quot;FIND &quot;jobname                                          
queue &quot;END&quot;                                                   
queue &quot;&quot;                                                      

/* allocate in-/out-dataset */                         
&quot;alloc dd(isfin)  new reuse unit(vioda)&quot;,                     
       &quot;recfm(f,b) lrecl(80) blksize(27920) space(1) tracks&quot;  
&quot;alloc dd(isfout) new reuse unit(vioda)&quot;,                     
       &quot;recfm(f,b,a) lrecl(301) blksize(27993) space(1) cyl&quot;  

/* write input-dataset from QUEUE */                       
&quot;execio * diskw isfin (finis&quot;                                 

/* SDSF-Call */                                             
PARM = &quot;/ ++20,400&quot;                                           
address LINKPGM &quot;SDSF PARM&quot;                                   

/* read isfout in out. */                
&quot;execio * diskr isfout (stem out. finis&quot;              
&quot;free dd(isfin,isfout)&quot;                               

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 = &quot;&quot;)
then do
   maxrc = &quot;XXMAXRC> JobId empty&quot;   
end
else do

/*   Returncode = 'CC 0000'     ===> 'R0000'  */
   if(left(maxrc,2) = &quot;CC&quot;)
                then maxrc = &quot;R&quot;!!SUBSTR(maxrc,4,4)

/*   Returncode = 'ABENDU3501'  ===> 'U3501'   */
   if(left(maxrc,6) = &quot;ABENDU&quot;)
                then maxrc = &quot;U&quot;!!SUBSTR(maxrc,7,4)

/*   Returncode = 'ABEND S0C7'  ===> 'S0C7 '   */
   if(left(maxrc,7) = &quot;ABEND S&quot;)
                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) ^= &quot;R&quot; & left(maxrc,1) ^= &quot;U&quot; & left(maxrc,1) ^= &quot;S&quot;)
                then maxrc = 'X'!!maxrc
end

return maxrc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top