Friday, June 5, 2020

REXX: How to set RC/MAXCC from REXX?

When you run your REXX in batch using ISPSTART, even if your program crashes, the job return code/MAXCC would be zero. This is not the result you want as you might have the following steps which would depend on this RC.

So, how to set the return code from REXX?

We need to make use of the system variable ZISPFRC.

if sysvar("SYSISPF") = "ACTIVE" then do         
   zispfrc = 16                                 
   address "ISPEXEC" "VPUT (ZISPFRC) SHARED"    
end                                             
exit                                            

This piece of code would set the return code of the batch to 16.

REXX: Print SDSF Spool output using REXX

The below code helps to print the spool out to the dataset. 
FILTER command is used to uniquely select the job output when the job names are same.
FILTER works only together with AFD REFRESH command. 
The program ISFAFD is the batch support for SDSF.

This REXX takes three inputs:
  • JOBNAME
  • JOBID
  • OUTPUT Dataset Name

ARG JOBNAME JOBID TEMPFILE                                              
ADDRESS TSO                                                             
"ALLOC F(ISFIN) TRACKS SPACE(1) REU" /* USED BY SDSF */                 
"ALLOC F(ISFOUT) NEW DELETE REU " , /* USED BY SDSF */                  
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)"               
"ALLOC F(TEMPPRT) DA('"TEMPFILE"("JOBID")')                             
      SHR  REUSE"                                                       
DROPBUF 0                                                               
QUEUE "PRE " JOBNAME  /* SDSF COMMANDS IN BATCH*/                       
QUEUE "H"                                                               
QUEUE "FILTER JobID EQ "JOBID                                           
QUEUE "AFD REFRESH"                                                     
QUEUE "SELECT "STRIP(JOBNAME) STRIP(JOBID)                              
QUEUE "++S"                                                             
QUEUE "PRINT FILE TEMPPRT" /* PRINT TO TEMP DATASET */                  
QUEUE "PRINT 1 999999"                                                  
QUEUE "PRINT CLOSE"                                                     
QUEUE "END"                                                             
"EXECIO" QUEUED()" DISKW ISFIN (FINIS" /* INPUT TO SDSF BATCH */        
ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,1000')"/* INVOKE SDSF */ 
"FREE FI(ISFIN)"                                                        
"FREE FI(ISFOUT)"                                                       
"FREE FI(TEMPPRT)"                                                      
RETURN 0                                                                

Featured Post

REXX Skeleton: Submitting jobs through Rexx

Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....