100% found this document useful (1 vote)
2K views33 pages

REXX Basics, Macros & Panels - Training

This document provides an outline for a training course on REXX fundamentals, macros, and panels. The outline includes sections on basic REXX concepts like control structures, arrays, file handling, and functions. It also covers creating and using REXX macros in ISPF EDIT, defining and interfacing with ISPF panels, and commonly used TSO functions. Sample REXX code is provided to illustrate key concepts.

Uploaded by

saha24
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views33 pages

REXX Basics, Macros & Panels - Training

This document provides an outline for a training course on REXX fundamentals, macros, and panels. The outline includes sections on basic REXX concepts like control structures, arrays, file handling, and functions. It also covers creating and using REXX macros in ISPF EDIT, defining and interfacing with ISPF panels, and commonly used TSO functions. Sample REXX code is provided to illustrate key concepts.

Uploaded by

saha24
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 33

REXX

FUNDAMENTALS, MACROS & PANELS

By
Karthik Shyam Manoharan
OUTLINE
REXX Basics

 Introduction to REXX
 Language Basics
 Control Structures
 Arrays
 File Handling & I/O
 Functions, String Manipulation

REXX EDIT MACROS & PANELS

 EDIT Macro Basics


 ISREDIT Services
 Panel Definition & Basics
 REXX – Panel Interfacing
REXX - Introduction
 REXX – Overview & Features
 REstructured eXtended Executor
 Interpreted Procedural Language
 Convenient built-in functions
 Good debugging and parsing capabilities
 Easy interfacing with ISPF services & TSO
 Good for automation and custom built applications
 Resource intensive
REXX – Language Basics
 Where to code a REXX program?
 How to Run a REXX program?
 Through TSO EXEC command
 Concatenate the PDS with REXX to SYSEXEC or
SYSPROC
Eg: “TSO ALLOCATE DD(SYSPROC) DA('DEB6028.REXX.EXEC') SHR REU”
 Type EX next to the member name
 Through JCL (IRXJCL)
REXX – Language Basics
 No declaration needed!
 Data type decided only on the first assignment
A=“STR”
B=124
C=A; C=B; C=D
 Arithmetic operators: ( + , - , > , < , = , \= , == )
 Logical operators: ( & , | , && , /)
 Concatenation operators ( || , blank space )
 SAY & PULL Statements
REXX - Control Structures
 Conditional Statements
 IF <condition> THEN
DO
<instructions>
END
ELSE
DO
<instructions>
END

 SELECT
WHEN <condition> THEN <instructions>
WHEN <condition> THEN <instructions>
OTHERWISE
<instructions>
END
REXX - Control Structures
 Looping Statements
 DO <variable> = <start> TO <end> [STEP] <value>
<instructions>
END

 DO WHILE <condition>
<instructions>
END

 DO UNTIL <condition>
<instructions>
END

 DO FOREVER
<instructions>
END
REXX - Control Structures
 Unconditional Control Transfer Statements
 ITERATE
Transfers control to the top of the loop

 LEAVE
Breaks the loop and transfers control to the next statement outside the loop

 EXIT <RC>
Exits the program to the calling environment with the return code specified

 CALL / RETURN
For calling subroutines within program
CALL <LABEL>
<LABEL> :
<instructions>
<instructions>
RETURN

 SIGNAL <LABEL>
Transfers control to the specified label
REXX - Arrays
 REXX Arrays – STEM fields
 STEM basics
Length of the array is contained in <STEMNAME>.0
1 DIMENSIONAL: <STEMNAME>.<SUBSCRIPT>
2 DIMENSIONAL: <STEMNAME>.<SUBSCRIPT1>. <SUBSCRIPT2>
Example: MYARR.1 = 2, MYARR.2 = E, MYARR.3=“C”, MYARR.0 = 3

 Length/Bounds need not be defined in the beginning


 Subscripts need not always be numerals
 Sparse arrays supported
 Group initialization allowed
REXX – Sample Programs
 Sample REXX Code: To illustrate how easy it is to capture data from TSO

SYSUSID=USERID()
SYSDATE = DATE()
SAY “Name Please : ”
PULL NAME
DO I = 1 TO 3
SAY “Hi!!! ” || NAME || “, your id is “ || SYSUSID
END
SAY “Today’s date is: “ SYSUSID
EXIT

 Test your REXX syntax:

Write a program to reverse the given number!


REXX – File Handling & I/O
 Allocate dataset to read
 “Alloc F(<ddname>) shr ds(‘dataset name’)”
 Read dataset using EXECIO – diskr
 "EXECIO * DISKR <ddname> (STEM <stemname.>"
 Write dataset using EXECIO – diskw
 "EXECIO * DISKW <ddname> (STEM <stemname.>"
 Close the dataset
 "EXECIO 0 DISKR <ddname> (Finis"
 Free the allocation
 “FREE F(<ddname>)
REXX - Some Commonly Used
String Functions
 PARSE
 INSERT(' ','abcdef',3) -> 'abc def'
 INDEX('abcdef','cd') -> 3
 LASTPOS(' ','abc def ghi') -> 8
 OVERLAY(' ','abcdef',3) -> 'ab def‚
 REVERSE('XYZ ') -> ' ZYX‘
 RIGHT('abc def',5) -> 'c def‘
 STRIP(' ab c ') -> 'ab c'
REXX – Some Commonly Used
TSO Functions
 SYSDSN
 SYSDSN(“MY.PDS(MEMNAME)") returns ‘OK’ if dataset is present

 OUTTRAP
OUTTRAP(‘<STEM.>’)
“TSO command”
OUTTRAP(‘OFF’)

 In General any TSO command can be invoked in a REXX and its results
can be captured in the program
 EG: LISTD ‘<MY.PDS(MEMNAME)>’ MEMBERS
The command needs to be given inside quotes in the REXX program and its result
can be trapped using OUTTRAP
“LISTD ‘DEB6028.REXX.EXEC’ MEMBERS”
REXX – Some Commonly Used
TSO Functions
 MSG(‘ON’) or MSG(‘OFF’)

 LISTDSI
 x = LISTDSI(work.exec)
 SAY 'Function code from LISTDSI is: 'x
 SAY 'The data set name is: ' sysdsname
 SAY 'The device unit on which the volume resides is:' sysunit
 SAY 'The record format is: ' sysrecfm
 SAY 'The logical record length is: ' syslrecl
 SAY 'The block size is: ' sysblksize
 SAY 'The allocation in space units is: ' sysalloc
 SAY 'Type of RACF protection is: ' sysracfa
REXX –File I/O Sample Program
 A REXX program to read a sequential dataset
change all occurrences of strings
“XYZ” to “ABC”
“X1Y1Z1” to “A1B1C1”
“X2Y2Z2” to “A2B2C2”

 Write a REXX program to display the


member names and number of members
REXX – ISREDIT Macro Basics
 These are nothing but REXX routines that can be
invoked from the command line of the edit window
 ISREDIT Macros have access to the data shown in
the edit windows
 All ISPF edit commands can be used in the REXX
Programs
 Easy to code and uses very little resources when
compared to other kinds of REXX programs
 Is also suitable for REXX programs invoking ISPF
panels
REXX – ISREDIT Macro Basics
 ADDRESS ISREDIT
 To communicate with ISREDIT
ADDRESS ISREDIT “<ISPF COMMAND>”
Eg: ADDRESS ISREDIT "MACRO PROCESS"
“ISREDIT F ALL ‘STRING’ 2”

 ADDRESS ISPEXEC
 To communicate with panel services
ADDRESS ISREDIT “<ISPF COMMAND>”
Eg: ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
“ISPEXEC SETMSG MSG(ISRZ001)"

 ADDRESS TSO
 To communicate with TSO – By default this is set as the program is invoked from TSO
Eg: File allocation commands
““ALLOCATE DD(SYSPROC) DA(‘DEB6028.REXX.EXEC’) SHR”
REXX – Sample REXX Macro
 REXX program to find the string in the current cursor position

/* REXX */
ADDRESS ISREDIT "MACRO PROCESS"
ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
MSG_STATUS=MSG('OFF')
"ISREDIT RES "
"ISREDIT (CROW,CCOL) = CURSOR"
"ISREDIT (CURRLINE) = LINE .ZCSR"
PARTSTR = SUBSTR(CURRLINE,CCOL)
BLNKPOS = INDEX(PARTSTR,' ')
FINSTR = SUBSTR(PARTSTR,1,BLNKPOS)
"ISREDIT F NEXT '"FINSTR"' "
REXX – Try it again using ISREDIT
Macro
 A REXX program to read a sequential dataset
change all occurrences of strings
“XYZ” to “ABC”
“X1Y1Z1” to “A1B1C1”
“X2Y2Z2” to “A2B2C2”

As you’ll find out, it’s a lot easier to code this


requirement using edit macro. It takes up very little
resource as the REXX macro is called from the
command line, after opening the sequential dataset in
edit/view mode
REXX - ISREDIT Services
 Two kinds of ISREDIT commands

 Those that can be issued only through macros


Examples:
"ISREDIT (CURLINE)= LINE .ZCSR"
"ISREDIT (LEND)= LINENUM .ZLAST"

 Those that can be issued in the command line as well as macros


Examples:
"ISREDIT RES"
"ISREDIT F ALL ‘PROGRAM-ID‘ "
"ISREDIT NUM ON STD COB"
REXX – More EDIT Macros

 This program removes COBOL comments in the edit window


and stores the commented code in a file

CODIN.TXT

 This program reads the file and inserts the COBOL


comments back into the program
CODOUT.TXT
REXX – ISPF Panel Definition
 Panel definition language is used to create ISPF
dialogs and panels
 They can be invoked from the ISPF dialog test
option for testing
 They can be displayed by REXX programs
 They consist of four main sections
 )ATTR – Sets the attributes for the special characters
 )BODY – Skeleton of the actual panel is described here
 )PROC – Used for minimal processing, like I/P validation
 )END – Signifies end of the panel
REXX – ATTR Section
ATTR – It defines the special characters and their attributes
 )ATTR
<SP.CHR> TYPE ([TEXT | INPUT]) INTENS ([LOW | HIGH]) COLOR
([GREEN | WHITE | RED …. ]) SKIP ([ON | OFF]) HILITE ([USCORE |
REVERSE | BLINK]) CAPS ([ON | OFF])

 Examples
)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON) CAPS(ON)
_ TYPE(INPUT) INTENS(LOW) COLOR(WHITE) HILITE(USCORE)
! TYPE(TEXT) INTENS(LOW) COLOR(RED)
$ TYPE(TEXT) INTENS(HI) COLOR(PINK)
REXX – BODY Section
BODY – It defines the skeleton of the panel
 The special character says whether the line (or part of the line) is an output
text line or an input line

 The special characters also define a number of other elements controlling


the display like color, intensity, effects etc

 There are default characters which have certain preset characteristics


 ‘+’ : Says that the line should be just treated as a hi intensity text and
should be displayed as it is
 ‘_’ : Says that what follows the ‘_’ symbol is an input field and can be
used by REXX to access the values contained

 The attributes of the default special characters can also be changed


REXX – )BODY Example
)BODY
$ -------------------------- ALTERNATE 3.4 MENU V1.0 -------------- BY: KARTHIK
%
% COMMAND ==> _ZCMD
%
+ ENTER SELECTION NO!('0' TO EXIT)+===> _C#
%
%
+ DSN@(1)_DSN1 # MODE (E/V/B) _M1#
%
%
+ DSN@(2)_DSN2 # MODE (E/V/B) _M2#
%
%
+ DSN@(3)_DSN3 # MODE (E/V/B) _M3#
%
%
+ DSN@(4)_DSN4 # MODE (E/V/B) _M4#
%
%
+ DSN@(5)_DSN5 # MODE (E/V/B) _M5#
REXX – ISPF Panel Definition
 )PROC – This section is mainly used for input
data validation. But it is advisable to handle
validation in the program invoking the panel

 )END – This just tells ISPF that the panel


definition has come to an end
REXX – Complete Panel Example
)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON) CAPS(ON)
)BODY
%----------------------------- COBOL FILE I/O CODER ----------------------------
%COMMAND : _ZCMD
%
+ NO OF I/P FILES USED ===> _IPFNUM # NO OF O/P FILES USED ===> _OTFNUM #
+ PGM NAME: _PGMNAME #
%
% INPUT FILES - INFORMATION AREA
%
% SNO DDNAME - COPYBOOK - I/P RECORD NAME
+ (1) _DDIF1 #- _CPIF1 # - _RCIF1 #
+ (2) _DDIF2 #- _CPIF2 # - _RCIF2 #
+ (3) _DDIF3 #- _CPIF3 # - _RCIF3 #
+ (4) _DDIF4 #- _CPIF4 # - _RCIF4 #
%
% OUTPUT FILES - INFORMATION AREA
%
% SNO DDNAME - COPYBOOK - O/P RECORD NAME
+ (1) _DDOF1 #- _CPOF1 # - _RCOF1 #
+ (2) _DDOF2 #- _CPOF2 # - _RCOF2 #
+ (3) _DDOF3 #- _CPOF3 # - _RCOF3 #
+ (4) _DDOF4 #- _CPOF4 # - _RCOF4 #
)END
REXX – Panel Interfacing
 Set the panel library

 Invoke the panel using the display command

 Read the panel input fields directly and


continue processing

 Throw error messages if required


REXX – Panel Interfacing
 Setting the panel library
ADDRESS ISPEXEC
"LIBDEF ISPPLIB DATASET ID(‘<PANELS.PDS>')“

 Invoking the panel library


ADDRESS ISPEXEC
"DISPLAY PANEL(<PANELNAME>)"

Note: <PANELNAME> is a member of <PANELS.PDS>


REXX – Panel Interfacing
 Reading panel fields
 Directly use the panel fields in the program

 In the body, if the line below is coded


+ PGM NAME: _PGMNAME #

 In the REXX program you can directly get the


value entered in the screen as shown below
MYREXXFIELD = PGMNAME
REXX – Panel Interfacing
 Populating error messages in the top right end of the
screen
 Populate system field ZEDSMSG for short error messages
 Populate system field ZEDLMSG for long error messages
 Throw error messages on the panel using SETMSG
command

 Example:
ZEDSMSG = "NO IF FILES IS INVALID"
ZEDLMSG = "NUMBER OF I/P OR O/P FILES INVALID"
ADDRESS ISPEXEC
"SETMSG MSG(ISRZ000)“
REXX – Questions?
Thank You

You might also like