Friday, January 17, 2020

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. 

Thursday, October 10, 2019

REXX: Delayed-Access Columns in SDSF


To create variables for the alternate field list including delayed access columns, the below ADDRESS SDSF command should be issued.

isfprefix = "your prefix *"
rc=isfcalls('on')
address sdsf "isfexec st (alternate delayed)"
do index=1 to jobid.ix
     say timer.index
     say dater.index
end

timer and dater are alternate field variables. They are introduced into your macro by the command (alternate delayed).

 Entire list of columns in ST panel is available at List of Columns in ST Panel.


Related topics: Accessing SDSF using REXX

Thursday, May 23, 2019

Debugging REXX - Trace Instruction

The TRACE instruction has several options for tracing, two of them are "commands" or "c" and "error" or "e".

TRACE C

When "trace c"  is specified in an exec, any command that follows is traced before it is executed, then it is executed, and the return code from the command is displayed.

For example, 

/*REXX*/                     
trace c                      
"listds 'dummy.ser.ds'"      
exit                         

This example results in the following error message.

     3 *-* "listds 'dummy.ser.ds'"         
       >>>   "listds 'dummy.ser.ds'"       
DUMMY.SER.DS                               
DATA SET 'DUMMY.SER.DS' NOT IN CATALOG     
       +++ RC(8) +++                       

TRACE E

When "trace e" is specified in an exec, any host command that results in a nonzero return code is traced after it executes and the return code from the command is displayed.

If an exec includes "trace e", the exec displays error messages, the line number and the command, and the return code from the command, as follows:

DUMMY.SER.DS                             
DATA SET 'DUMMY.SER.DS' NOT IN CATALOG   
     3 *-* "listds 'dummy.ser.ds'"       
       +++ RC(8) +++                     
***                                      

Saturday, May 18, 2019

Abend 878000 hex occurred processing command 'EXEC '.

"Abend 878000 hex occurred processing command 'EXEC '." This error message occurs while executing REXX when there is insufficient virtual storage.

Possible solutions:

  • Check if you are using EXECIO * DISKR. In this case, the input data might be too large which may cause allocation error. 

          To avoid this error, execute the same REXX in background mode using JCL with maxium                    REGION parameter value. 

  • Try logging out of the session, login again and execute the REXX again.

Friday, May 17, 2019

REXX: External Functions

In addition to in built functions, REXX provides external functions to do specific tasks

SYSDSN:

This function returns OK if the specified data set exists; otherwise, it returns an appropriate error message.

The input for this function is a dataset name.

Example:

if SYSDSN(" ' Your Dataset ' ") /= 'OK' then do       
    say "Dataset doesn't exist. ' 
end

SYSVAR:

This function uses specific argument values to return information about the user, terminal, language, exec, system, and console session.

Example:

userid = SYSVAR(SYSUID)
say userid

This would return the userid who is logged in.

SETLANG:

This function is used to determine the currently language being used and also it allows us to change the language.

Example:

 curlang=SETLANG()
 say curlang 

OUTTRAP:

This function puts lines of command output into a series of numbered variables, each with the same prefix. These variables save the command output and allow an exec to process the output. Specify the variable name in parentheses following the function call.

Example:
x = OUTTRAP('att')
"LISTC"

att0 - will contain the no. of lines stored.
att1 - will contain the first line
att2 - will contain the second line and so on

you can also use STEM variables as parameter.

Example:

x = OUTTRAP('out.')
"LISTC"

out.0 - will contain the no. of lines stored.
out.1 - will contain the first line
out.2 - will contain the second line and so on

LISTDSI:

This function lists the dataset information.

Example:

x = LISTDSI(" ' Your Dataset ' ")

This statement will populate many system variables.

for ex:
SYSDSNAME
SYSRECFM 
SYSLRECL 
SYSBLKSIZE
SYSKEYLEN
SYSALLOC
SYSUSED
SYSUSEDPAGES
SYSPRIMARY
SYSSECONDS
SYSUNITS
SYSEXTENTS
SYSCREATE

Thursday, May 16, 2019

How to get the ZOS DB2 Version in mainframe?

Go to QMF or Spufi.

Execute the below query.

SELECT GETVARIABLE('SYSIBM.VERSION') FROM SYSIBM.SYSDUMMY1

The result would be of format pppvvrrm.

ppp - product string
vv  - Version
rr - Release number
m - Modification level

Example: DSN11015 means DB2 Version 11 in new-function mode.

DSN - DB2 for z/OS
11 - DB2 Verison 11
5 - modification level 5 means New-function mode.

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