The first REXX program is very simple. It calls out the world.
/* REXX */
SAY 'HELLO WORLD'
Put this in a PDS member (ideally, create one like myhlq.REXX.EXEC).
Now, there are various ways by which you can invoke a REXX program.
1. From ISPF main panel, run the command
TSO EX 'myhlq.REXX.EXEC(HELLO)' EX
2. From READY Prompt, run the command,
EX 'myhlq.REXX.EXEC(HELLO)' EX
3. Using 3.4, browse to the PDS myhlq.REXX.EXEC.
Before the member HELLO, enter EX and press enter.
The above are the manual methods. What follow below are smart methods to run REXX program.
To understand the smart way, it is first important to undestand the concept of REXX libraries.
When you logon to ISPF, ISPF assigns a pre-defined set of DDNames to few PDS datasets. To view this set, you can enter the command TSO ISRDDN from the ISPF panel.
From the list displayed, the DDnames of interest here are SYSEXEC and SYSPROC. The PDS datasest shown against these DDnames are the PDS that TSO will look for, when you don't specify the PDS name and just specify the REXX program name to run. If you want to run your REXX program the smart way, you need to assign your personal PDS (myhql.REXX.EXEC) to this list for SYSEXEC or SYSPROC.
There are two ways to do this.
i. If your system adminstrator allows, you can run a CLIST or REXX program when you logon to ISPF. This will usually appear as a message when you logon. Ask you system admin if you can do this, as this is the best way to do this.
If it is a CLIST, add the following command in the CLIST,
CONCATD FI(SYSEXEC) DA('myhql.REXX.EXEC')
If it is a REXX, add the following command,
"ALLOC FILE(SYSEXEC) DATASET("'myhql.REXX.EXEC'","'isp.rexx.exec') SHR REUSE"
Note that in this case, you need to specify all the existing allocations to SYSEXEC (from ISRDDN). If you just specify your PDS in the DATASET, then the existing allocations will be lost.
ii. If the system admin does not allow running a REXX/CLIST, then execute the following command one time in your ISPF session.
TSO ALTLIB ACTIVATE APPL(EXEC) DSN('myhlq.REXX.EXEC')
The drawback of this method is that it works only in the session that you execute from. If you have more than one session open using split screens (this is the norm nowadays), you need to execute this command in all your sessions.
So, work out the best way that works for you.
Once the above is done,
4. You just need to execute command from ISPF,
TSO HELLO
5. From READY prompt, just enter
HELLO
6. You can also run the REXX program through a JCL. The following is the JCL step that you need.
//REXXBTCH EXEC PGM=IKJEFT01
//SYSEXEC DD DSN=MYHQL.REXX.EXEC,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
%HELLO
/*
If you have ISPF services within your REXX, then you need additional DDnames in your JCL step. You will essentially start ISPF in batch and then run the rexx program so that all the ISPF services are available when it runs in batch.
//REXXBTCH EXEC PGM=IKJEFT1B
//ISPLLIB DD DISP=SHR,DSN=USER.ISPLLIB
//ISPPLIB DD DISP=SHR,DSN=ISP.SISPPENU
//ISPMLIB DD DISP=SHR,DSN=ISP.SISPMENU
//ISPSLIB DD DISP=SHR,DSN=ISP.SISPSENU
//ISPPROF DD DSN=&TEMPPROF,DISP=NEW,PASS,DELETE)
//ISPLOG DD SYSOUT=*,DCB=(RECFM=VA,LRECL=125,BLKSIZE=129)
//ISPTABL DD DISP=SHR,DSN=&TEMPPROF
//ISPTLIB DD DISP=SHR,DSN=&TEMPPROF
// DD DISP=SHR,DSN=ISP.SISPTENU
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSEXEC DD DISP=SHR,DSN=MYHLQ.REXX.EXEC
//SYSTSIN DD *
ISPSTART CMD(%HELLO)
/*
Add additional DDnames as required in your installation. Contact your system admin for the correct list of concatenations required.