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                                                                

Wednesday, April 8, 2020

JCL: Abend S013 SYSTEM COMPLETION CODE=013 REASON CODE=00000018

Abend S013 SYSTEM COMPLETION CODE=013  REASON CODE=00000018

AN OPEN WAS ISSUED FOR A PARTITIONED DATASET. THE SPECIFIED MEMBER NAME WAS NOT FOUND IN THE DATASET. S013 1C - AN OPEN MACRO WAS ISSUED FOR A PARTITIONED DATASET, BUT AN I/O WAS ENCOUNTERED SEARCHING THE DIRECTORY.

A mentioned PDS member in the jcl is not found during execution. The DDNAME and the dataset name could be found with this information IEC141I.

Monday, April 6, 2020

Windows 10: User Startup folder location

Windows 10 Startup Folder Location

If you want to add a program, URL or document to startup you should place its shortcut to user startup folder. By default it is located in:
C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Thursday, March 5, 2020

REXX: Reading the dataset name of a DDNAME

/* REXX */
ddinfo = LISTDSI("DDNAME" "FILE")   
Say "Dataset Name: "SYSDSNAME     
Say "RC : " ddinfo
Exit

To run this REXX in background mode, use IKJEFT01 utility. Also, note LISTDSI works well with IKJEFT01 utility.

An incorrect ddname would lead to RC 16.

If the keyword "FILE" is ignored, LISTDSI would assume that the given value is a dataset name.

If you'd like to know the sysexec dataset of your profile, try "SYSEXEC" in place of the ddname. This can be run in foreground mode.

Wednesday, February 5, 2020

REXX: How to execute IMS region commands?

I have the requirement to restart the IMS region by issuing command

/STO REG <region no>

and then

/STA REG <Region Name>

How to achieve this in REXX?


Solution:

ADDRESS LINK  'CSLULXSB'                           
ADDRESS IMSSPOC                                   
"DIS SUBSYS ALL"                                   
"IMS <IMSPlex>"                     
"ROUTE <IMSPlex member>"                     
"CART DISTRAN"                                     
"/STOP REGION "REGION_NO                           
STOP_RC = CSLULGTS('STOINFO.','DISTRAN',"59")     
DO J=1 TO STOINFO.0                               
   Say STOINFO.J                                   
END                         


<IMSPlex> - Your system programmer would know it.
<IMSPlex member> - The region where your command would be executed.

Very important: You need to add your steplib for this REXX to work.

"STEPLIB ADD DA('SYSC.IMSDBCN.SDFSRESL.<IMSPlex member>') NOMSG"                    

In this library, you will find the member CSLULXSB. This is to ensure that you are adding the correct library.

Friday, January 17, 2020

REXX: Removing Junk Character in dataset using REXX

/* REXX */           
ADDRESS ISREDIT      
"MACRO"              
"C ALL P'.' ' '"     



Save this rexx under remjunk and run it over a dataset to replace all junk characters with spaces.

REXX: Reading JOB Status using REXX

/* REXX */                                                              
X = OUTTRAP('SLINE.')                                                   
"STATUS <JOBNAME> <JOBID>"                                                       
D = OUTTRAP("OFF")                                                      
count = 0                                                               
DO I = 1 TO SLINE.0                                                     
   SAY SLINE.I                                                          
     PARSE VAR SLINE.I JOBHOLDER NAME MESSAGE                           
      STRT_POS     =  POS("(",NAME,1)                                   
      END_POS      =  POS(")",NAME,1)                                   
      LENG_NAM     =  STRT_POS - 1                                      
      STRT_POSID   =  STRT_POS + 1                                      
      LENG_JOBID   =  END_POS - STRT_POSID                              
      JOBNAM       =  SUBSTR(NAME,1,LENG_NAM)                           
      JOBID        =  SUBSTR(NAME,STRT_POSID,LENG_JOBID)                
      IF MESSAGE = "EXECUTING" THEN                                     
          DO                                                            
            SAY " ONLY JOBS ON OUTPUT CAN BE BROWSED "JOBID" "MESSAGE   
          END                                                           
      IF MESSAGE = "ON OUTPUT QUEUE"   THEN                             
          DO                                                            
            COUNT = COUNT + 1                                           
          END                                                           
      IF MESSAGE = "NO JOBS FOUND" THEN                
          DO              
            SAY MESSAGE   
            RETURN        
          END             
END                       

EXIT                      

                 
Note: Replace JOBNAME and JOBID in the rexx and execute to see the results.

You may also ignore JOBID to get the list of all jobs with that job. 

"STATUS <JOBNAME>"

REXX: Setting dataset profile using REXX MACRO

/* REXX */                            
ADDRESS ISREDIT                       
"MACRO (PARM)"                        
PARM = TRANSLATE(PARM)                
IF PARM = "COBOL" ! PARM = "" THEN    
DO                                    
   "HI COBOL"                         
   "STATS ON"                         
   "CAPS OFF"                         
END                                   
IF PARM = "REXX" THEN                 
DO                                    
   "HI REXX"                          
   "STATS ON"                         
   "CAPS OFF"                         
END                                   
IF PARM = "JCL" THEN                  
DO                                    
   "HI JCL"                           
   "STATS ON"                         
   "CAPS OFF"                         
END     
EXIT               

Save this REXX macro as SETPROF.

Examples:

To set the profile for JCL :  TSO SETPROF JCL
To set the profile for REXX : TSO SETPROF REXX
To set the profile for COBOL : TSO SETPROF (or) TSO SETPROF COBOL

Executing this macro without any parameters would set the profile for COBOL. 

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....