REXX Programming: Arsalan-Meenal
REXX Programming: Arsalan-Meenal
REXX Programming: Arsalan-Meenal
Arsalan- Meenal
What is REXX
Ease of use
The REXX language is easy to read and write because many instructions are
meaningful English words
Free format
There are few rules about REXX format You need not start an instruction in a
particular column, you can skip spaces in a line or skip entire lines, you can have
an instruction span many lines or have multiple instructions on one line, variables
do not need to be predefined, and you can type instructions in upper, lower, or
mixed case
Convenient built-in functions
REXX supplies built-in functions that perform various processing, searching, and
comparison operations for both text and numbers
Debugging capabilities
You can use the REXX TRACE instruction and the interactive debug facility to
locate errors in execs
Interpreted language
TSO/E implements the REXX language as an interpreted language When a REXX
exec runs, the language processor directly processes each language statement
Extensive parsing capabilities
REXX includes extensive parsing capabilities
What is a REXX Exec?
Running Explicitly:
You can specify a data set name according to the TSO/E data set naming
conventions in several different ways. For example the data set name
USERID.REXX.EXEC(REXX01) can be specified as:
A fully-qualified data set, which appears within quotation marks.
EXEC 'userid.rexx.exec(rexx01)' exec
A non fully-qualified data set, which has no quotation marks can eliminate
your profile prefix (usually your user ID) as well as the third qualifier, exec.
EXEC rexx.exec(rexx01) exec /* eliminates prefix */
EXEC rexx(rexx01) exec
Where to type exec command for explicit
execution:
At the READY prompt
READY
EXEC rexx.exec(rexx01) exec
The ALTLIB command offers several functions, which you specify using the following operands:
ACTIVATE Allows implicit execution of execs in a library or libraries on the specified level(s), in
the order specified.
DISPLAY Displays the current order in which exec libraries are searched for implicit execution.
RESET Resets searching to the system level only (execs allocated to SYSEXEC or SYSPROC).
Writing a REXX
REXX programs are called EXEC
Begin an exec with a comment line which includes the word REXX.
Like a CLIST, a REXX exec can contain TSO/E commands to be executed when the exec runs.
Generally, to differentiate commands from other types of instructions, enclose the command within
single or double quotation marks.
TSO/E commands, one of which is ALLOCATE, require keywords followed by parentheses.
"ALLOC DA(NEW.DATA) LIKE(OLD.DATA) NEW“
If the ALLOCATE command in the example above was not enclosed in quotation marks, the
parentheses would indicate to the language processor that DA and LIKE were function calls, and the
command would end in an error.
Using ISPF EDIT Macro written in REXX we can invoke all services provided
by ISPF Editor.
The REXX exec should contain MACRO command to indicate that this is a
REXX macro.
ADDRESS ISREDIT “MACRO”
Example of a EDIT MACRO. This MACRO issues ISPF find command through REXX exec.
/* REXX */
ADDRESS ISREDIT "MACRO"
STR = ‘SOME DATA'
ADDRESS ISREDIT
"FIND " STR " ALL
3) Executing EXEC through JCL
Sometimes when we need to execute a REXX at the backend (in batch) ,that can be also be
achieved.
You can run time-consuming and low priority execs in the background,or execs that do not require
terminal interaction.
The program IKJEFT01 sets up a TSO/E environment from which you can invoke execs and
CLISTs and issue TSO/E commands.
In a DD statement, you can assign one or more PDSs to the SYSEXEC or SYSPROC system file.
The SYSTSPRT DD allows you to print output to a specified data set or a SYSOUT class.
In the input stream, after the SYSTSIN DD, you can issue TSO/E commands and invoke execs
and CLISTs.
We can also use IKJEFT1B or IRXJCL to execute REXX EXEC.
4) Handling Datasets:
DD – Represent the DD name of the files which has been allocated in DSNAME
DSNAME – Represents the dataset name to be allocated.
Handling Datasets(cntd.):
Reading a Dataset:
Writing a Dataset:
Freeing a Dataset:
“ FREE DD(INFILE) “
FREE Command to free the dataset at end of the processing.
Handling Datasets(cntd.):
Some Examples:
1) Reading all records from the dataset into a compound variable:
"EXECIO * DISKR myindd (FINIS STEM newvar.“
newvar.0 will contain the total number of records populated in the stem