How can I run my Rexx program as a batch job?

MikeT picture MikeT · Aug 10, 2016 · Viewed 8.3k times · Source

I have a Rexx program that I want to run as a batch job. How can I do this?

This is my program :-

/* Rexx – HELLO – Write Hello World */
Say "hello World"

The program is located as member HELLO in the PDS ME.USER.EXEC.

A valid JOB CARD for my installation is (our environment includes ISPF/PDF as opposed to ROSCOE):-

//MYJOB    JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID

Note! this has been written as a tutorial

Answer

MikeT picture MikeT · Aug 10, 2016

There are a number of ways that you can run the program via batch. I will cover 3 ways all of which are different according to the environment (i.e. what they can utilise.)



Method 1 - Run the program in a Rexx environment.

This entails running the program IRXJCL and passing the name of the program (i.e. the PDS's member name) via the PARM field (you can also pass parameters; accessing them via a PARSE ARG statement).

IRXJCL requires (normally) 3 DDNAMES they are SYSEXEC (The PDS where the program is located), SYSTSIN (this can reflect terminal input) and SYSTSPRT (this is where terminal output is sent).

Here is the JCL that would work according the information provided above:-

//MYJOB    JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG  EXEC PGM=IRXJCL,PARM=’HELLO’
//*
//*        RUN OUR REXX PROGRAM CALLED HELLO
//*
//SYSEXEC  DD DSN=ME.USER.EXEC,DISP=SHR
//SYSTSIN  DD DUMMY
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------

This method, although the simplest (by just a few lines of JCL), is the most restrictive in that it does not allow the use of TSO/E services, such as TSO/E commands and most of the TSO/E external functions.

However, as IRXJCL is a Rexx processor, there is no requirement to let TSO/E know that it is a Rexx program (the first line must include REXX).



Method 2 - Run the program from a TSO/E environment

This entails running one of the TSO/E batch processing programs IKJEFT01 is used in this example. Alternatives are IKJEFT1A and IKJEFT1B. TSO/E services and commands can be used via this method (e.g. note at end of this method using the TIME command)

Comprehensive information about the differences between the programs can be found at Writing JCL for command execution

The JCL for IKJEFT01 is similar to that used in Method 1. An additional DDNAME SYSPROC can be coded. SYSPROC is the DDNAME where CLISTS would be located; You can have Rexx programs found here in addition to SYSEXEC (which isn't required, a suggestion is that both are coded and that SYSEXEC is used for Rexx programs and SYSPROC is used for CLISTS).

It's the requirement that Rexx is on the first line that differentiates a Rexx program from a CLIST (by the TSO/E processor). Thus, if the Rexx program is found/located via SYSEXEC, if I recall correctly, this negates the requirement).

Another suggestion is to always include REXX in the first line of a Rexx program>

The EXEC statement invokes the IKJEFT01 program instead of IRXJCL. PARM can be used to specify the first command (and therefore our HELLO program). However, as for foreground, you can specify this via the terminal i.e. the SYSTSIN DDNAME.

Here is some JCL that would work for the second method; noting that the HELLO program is invoked via the SYSTSIN DDNAME as instream data :-

//MYJOB    JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG  EXEC PGM=IKJEFT01
//*
//*        RUN OUR REXX PROGRAM CALLED HELLO IN A TSO/E ENVIRONMENT
//*
//SYSPROC  DD DSN=ME.USER.CLIST,DISP=SHR
//SYSEXEC  DD DSN=ME.USER.EXEC,DISP=SHR
//SYSTSIN  DD *
 HELLO
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------

If, for example, the following were used (i.e. added TIME as another line to SYSTSIN) then the TSO/E TIME command would be run (which would cause the time to be displayed to SYSTSPRT).

//SYSTSIN  DD *
     HELLO
     TIME


Method 3 - Run the program in an ISPF environment

This method uses the IKJEFT01 program (see method 2 for IKJEFT1A/B alternatives). However, it then uses the ISPSTART command to run the program in an ISPF environment; enabling the use of ISPF services (e.g file tailoring (skeletons) ISPF tables etc).

An ISPF environment has additional requirements in that ISPF libraries need to be allocated in order to start an ISPF environment. At a minimum have the supplied ISPF libraries allocated to ddnames ISPPLIB (ISPF Panels), ISPMLIB (ISPF Messages) & ISPTLIB (ISPF Tables). ISPPROF is where ISPF keeps some profile data for the session, so a temporary store is sufficient (UNIT=SYSDA is often available if not always).

Note you would likely allocate, at a minimum, the installations system libraries (the TSO/E command LISTA can likely be used to determine these from a foreground session). Alternately, ask you local friendly system programmers. In the following they are SYS1.ISPPLIB, SYS1.ISPMLIB and SYS1.ISPTLIB.

Here is some JCL that would work for the 3rd method. Note that HELLO is passed as a parameter to the ISPSTART command.

//MYJOB    JOB ,,CLASS=1,MSGCLASS=H,NOTIFY=&SYSUID
//*-------------------------------------------------------------------
//RUNPROG  EXEC PGM=IKJEFT01
//*
//*        RUN OUR REXX PROGRAM HELLO IN A TSO/E/ISPF ENVIRONMENT
//*
//SYSPROC  DD DSN=ME.USER.CLIST,DISP=SHR
//SYSEXEC  DD DSN=ME.USER.EXEC,DISP=SHR
//ISPPLIB  DD DSN=SYS1.ISPPLIB,DISP=SHR
//ISPMLIB  DD DSN=SYS1.ISPMLIB,DISP=SHR
//ISPTLIB  DD DSN=SYS1.ISPTLIB,DISP=SHR
//ISPPROF  DD UNIT=SYSDA,SPACE=(CYL,(10,1)),
//            RECFM=FB,LRECL=80,BLKSIZE=0
//SYSTSIN  DD *
 ISPSTART CMD(HELLO)
//SYSTSPRT DD SYSOUT=*
//*-------------------------------------------------------------------

Note this is not a fully comprehensive, it is an overview that should suffice for getting started with running Rexx programs in batch.