Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

REXX Programming: Arsalan-Meenal

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 19
At a glance
Powered by AI
The key takeaways are that REXX is an interpreted programming language that is easy to use and works across platforms.

Some features of REXX include ease of use, free format, convenient built-in functions, debugging capabilities, and extensive parsing capabilities.

A REXX Exec consists of REXX language instructions that are interpreted directly by the REXX interpreter. An exec can also contain commands that are executed by the host environment.

REXX Programming

Arsalan- Meenal
What is REXX

 Restructured Extended Executer


 Its an Interpreter Language which is extremely versatile
 Works in all platforms
 Most popular in Mainframe
 Can be executed by any TSO user
 Can use multiple utilities/subsystem eg TSO, ISPF, DB2,
SDSF etc
Features of 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?

 A REXX exec consists of REXX language instructions that are


interpreted directly by the REXX interpreter An exec can also contain
commands that are executed by the host environment

 Example of a Simple Exec

/******************** REXX *****************/


SAY 'This is a REXX exec'
Running an Exec

REXX EXEC Can be executed two ways:


1. Running an Exec Explicitly
The EXEC command runs non-compiled programs in TSO/E. To run an exec
explicitly, enter the EXEC command followed by the data set name that contains the
exec and the keyword operand "exec" to distinguish it from a CLIST.

2. Running an Exec Implicitly


Running an exec implicitly means running an exec by simply entering the member
name of the data set that contains the exec.
Lets seee that using Examples: 

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

 From the COMMAND option of ISPF/PDF

 On the COMMAND line of any ISPF/PDF panel as long as the EXEC


command is preceded by the word "tso".
Implicit Execution:

 Here the First Step is to allocate the PDS to system files:

Several ways to do that ….

1) Using EXEC to setup the PDS to SYSEXEC.

2) Using ALTLIB command:


ALTLIB Command Contd:

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.

 DEACTIVATE Excludes the specified level from the search order.

 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

 Allocate a dataset or PDS to write REXX programs

 Begin an exec with a comment line which includes the word REXX.

 Comment line in REXX begins with /* and ends with */

 Placement of comments and instructions in one line is possible.

 Requires one or more blank to separate arguments.

 Arguments can be in any case.

 To combine related statements use a semi colon to separate them.\

 To continue a statement, other than a comment on next line use comma to


indicate continuation.
REXX usage scenario

1)Execute TSO commands


2)Execute ISPF commands
3)Execute REXX through JCL
4)Can Manipulate/Handle Datasets
5)Can create Front End screens like CICS
1.) Executing TSO commands:

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

We can check one simple example for the same :


ESDSMXT.REXX.EXEC(REXX02)
2) Executing ISPF commands:

 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:

Allocating a DD name to a file

 “ALLOC DD(INFILE) DSNAME(‘XXX.ABC’) SHR REUSE”


 “ALLOC DD(INFILE) DSNAME(‘XXX.ABC’) MOD REUSE”
 “ALLOC DD(INFILE) DSNAME(‘XXX.ABC’) NEW
CATALOG UNIT(SYSDA) CYL SPACE(1 1) RECFM(FB)
LRECL(80) BLKSIZE(0) RELEASE REUSE”

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:

Syntax for read operations :


EXECIO {lines ¦ *} DISKR ddname {linenum} { ( {{FINIS}} ¦ { STEM var {FINIS} } {)}
}
E.g.

"EXECIO * DISKR INFILE (FINIS STEM INLINE.“

 EXECIO Command to perform file input/output operation.


 DISKR Command to read a file
 FINIS Command to tell EXECIO to close the dataset when it is finished reading all
the records.
 STEM Command which specifies that data will be stored in a STEM by name
INLINE.
Handling Datasets(cntd.):

Writing a Dataset:

“EXECIO * DISKW INFILE (FINIS STEM INLINE.”


 DISKW Command to write record to the file.

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

2) Reading all records starting from record 100:


"EXECIO * DISKR myindd 100 (FINIS“

3) Reading 6 records starting from record 50:


"EXECIO 6 DISKR myindd 50 (FINIS“
5) Front end Screens Like CICS:

SAMPLE PANEL DEFINITION:


)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON)
)BODY
%-------------------- ENTRY PANEL -----------
%COMMAND ===>_ZCMD
%
+EMPLOYEE NUMBER ===> _EMPNO #
+DEPARTMENT ===> _DEPT#
%
)END

You might also like