TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

Basics of Rexx

After completing this chapter, you will be able to:

  • Explain the general format of REXX

  • List the basic instructions

REXX (Restructured EXtended eXecutor) is a powerful interactive programming language that can execute system commands, such as TSO, ISPF etc. It allows you to:

  • Request information from the terminal and Display output on terminal.

  • Execute TSO commands under program control.

  • Develop custom-made utilities.

  • Read and write files.

REXX is more modern, powerful interpreted command language, and is procedural language that allows programs and algorithms to be written in a clear and structured way. It is easy to use by experts and casual users alike.

REXX has the capability to issue commands to its host environment and to call programs and function written in other languages.

Features of REXX:

The features of REXX are as follows:

  • Ease of use

  • Free Format

  • Convenient built-in functions

  • Debugging capabilities

  • Interpreted language

  • Extensive parsing capabilities

General Format of REXX Statements:

The mandatory statement in REXX is /*REXX*/ . This statement should be included at the beginning of every REXX programs. REXX supports free-format statements:

  • Which can appear anywhere between columns 1 and 72.

  • Can have any number of embedded blanks.

  • Can be terminated with either an end-of-line character or a semicolon (;).

  • More than one statement can be included in one line separated from each other by a semicolon.

  • One statement can span more than one line, in which case a comma at the end of the line indicates a continuation of the statement.

  • Comments appear between the delimiters /* and */ and can span one or more lines.

The general form of a REXX statement is [Label:] term [;] where term is either a comment or an expression.


/* Simple Statement*/ Say ‘Hi’

/*Statement using comma to span two lines*/ Say ‘Using comma’,
‘To span two lines’

/*Statements using semicolon in a single line*/
Say ‘Semicolon’; Say ‘used to write multiple statements in a single line’.

Creation of REXX EXEC:

Before you can write a REXX program called EXEC, you need to create a dataset to contain the exec. The dataset may be either sequential or partitioned, but if you plan to create more than one exec, it is easier to create a REXX library as a Partitioned Data Set (PDS).

It is recommended to allocate the dataset with your prefix as the first qualifier, any name as the second qualifier and preferably exec as the third qualifier.


Tips and Tricks:

Always it is better to call REXX programs as REXX exec.

Instructions in REXX EXEC:

REXX instructions are categorized as follows:

  • Keyword

  • Assignment

  • Label

  • Null

  • Command


A keyword instruction tells the language processor to perform some operation. It begins with a REXX keyword that identifies what the language processor is to do. For example (SAY displays a string on the screen).


An assignment gives a value to a variable or changes the current value of the variable.

For example (A=4).


A label is a symbolic name followed by a colon. A label can contain either single- or double- byte characters or a combination of both. A label identifies a portion of the exec and is commonly used in subroutines and functions, and with the signal instruction.


A null is a comment or a blank line, which is ignored by the language processor but make an exec easier to read.


An instruction that is not a keyword instruction, assignment, label, or null is processed as a command and is sent to a previously defined environment for processing.

For example ("TIME").


  • The only mandatory statement in REXX is '/* REXX */'.

  • REXX statements are delimited by ';' and Comma is used the continuation character.

If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal