Wednesday, December 12, 2007

REXX – How to write a hello world program

REXX – Restructured Extended Executer

What is REXX?

REXX is a scripting language like Perl, UNIX shell scripts and developed by IBM. You can use REXX to simplify the admin tasks like creating bulk no.of users, creating bulk datasets, recalling bulk datasets etc…and also it can be used in Panel programming.

If you don’t have any idea about script language, you can assume REXX is used to execute the collection of system commands according to our logic. This logic can be coded using control constructs like IF..THEN..END,DO..END etc..

So REXX will ease the work of administrator, With out REXX it will be very difficult to perform any large or repetitive tasks.

If you already know any programming languages then REXX will be very easy to learn.


Steps to create REXX program

1) Create a sequential dataset with RECFM=FB, LRECL=80 or it can be a member of any PDS with these attributes

2) Code the following

Line1:  /*REXX*/ 
Line2:  
CLEAR  
Line3:  
SAY ‘Welcome to rexx coding’  

Notes:

/* */ - any statement with in this will be considered as comment.
Line1:The first line of the any REXX script must contain the word 'REXX'
Line2: to clear the screen
Line3: to display the string 

3) Save it

4) You can execute it by the following ways

Assumes you have the coding in the dataset ‘HLQ.NAME.EXEC(FIRST)’

Then

• From TSO ready prompt you can type EXEC ‘HLQ.NAME.EXEC(FIRST)’ EXEC [Explicit Execution]
• Or you can first concate your PDS to SYSEXEC DD and type %FIRST in TSO ready prompt.[Implicit Execution]
• Or typing EX at DSLIST(Option 3.4) line command area




Note:

To concate the PDS to SYSEXEC DD use the following command

CONCAT DD (SYSEXEC) DS (‘HLQ.NAME.EXEC(FIRST)’)


Basic way of coding REXX

Normally we code the REXX in the following way

1) Execute some system commands by using REXX
2) Collect the Output of that commands to the Stem* variables
3) Process the data which we have collected in stem variable according to our logic or execute some other system commands

*Stem variable – you can assume it as a array variable


For example if your aim is to find the Name of a particular userid then

1) You have to identify the required system commands.In this case you can use
RACF command LU

2) The output of the command will contain the name field which contains the name information of the person. So to not displaying all the info in the screen you will use
Outtrap REXX command to capture the output of the command to a stem variable.

3) Then you will extract only name info from the stem variable and display it on the screen.


Final Words

By using REXX you can do a lot of stuff like panel progrmming etc.. REXX will save a lot of time and efforts of the SYSPROG.So it is a good idea to learn REXX.

The purpose of this article is just to give you a basic idea of REXX. So don’t worry if you couldn’t understand any topics.

If you are interested in REXX, I suggest you to refer REXX user guide from IBM Redbooks.

Your comments are always welcome.

Best of luck.

2 comments:

Anonymous said...

very nice article...Cool

Ganeswar said...

Learn more in this link
https://www.tutorialspoint.com/rexx/rexx_decision_making.htm