Title.

REXX Interlanguage Communication in MVS; Calling REXX from COBOL


Abstract.

This article describes how to call a REXX exec from within a COBOL
program under the MVS operating system (including the MVS component of
S/390 and z/OS).

Example batch jobs are given which include passing parameters from the
COBOL program to the REXX exec and returning values to the COBOL caller.

Both the IRXJCL and IRXEXEC interfaces are used.


Contents.

This article describes how to call a REXX exec from a COBOL program
under MVS and illustrates by means of two example jobs how to pass
parameters back and forth between the COBOL and REXX programs.

Use is made of the IRXJCL and IRXEXEC interfaces.  These interfaces are
available in any address space and are applicable to interpreted and
compiled REXX execs.  However, the jobs shown below illustrate the use
of interpreted programs.

Each job consists of:

- a step which copies the REXX exec as a member into a temporary
  partitioned data set.

- an invocation of a cataloged procedure to compile, link and execute
  the COBOL program for calling the REXX exec.  The execute step is
  assigned additional DD statements needed by the REXX exec.

The IRXJCL interface is easier to use but does not offer so much
flexibility as the IRXEXEC interface.  With IRXJCL:

- you do not have to do so much coding, only the parameters for the call
  to IRXJCL need be set up.

- you can only pass one argument string to the REXX program, however
  this string may contain any number of tokens/words.

- the REXX exec may only pass back a numeric return code, limited to a
  maximum of 4095 (decimal).

With the IRXEXEC interface:

- more coding is involved due to setting up the Exec Block and
  Evaluation Block as well as the arguments to IRXEXEC.  The Exec
  Block is a control block that describes the REXX exec to be
  loaded. The Evaluation Block is mentioned below.

- multiple argument strings are allowed and each argument string may
  consist of multiple tokens/words.

- the REXX exec may return to its caller, by using the RETURN or EXIT
  clause, a variable length character string consisting of any number of
  tokens/words.  This character string and its length is returned in a
  control block called the Evaluation Block.  However, in the example
  below the character string is restricted to a maximum length of 256
  bytes.

For more information concerning the IRXJCL and IRXEXEC routines and the
control blocks involved in these examples, please consult the TSO/E REXX
Reference manual, IBM document number SA22-7790, Chapter 12.  An on-line
version of this publication is available, see:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A320/

Example 1 IRXJCL

/*%include 'RXT.INITLANG.CNTL(SJCLCOB)'

Example 2 IRXEXEC

/*%include 'RXT.INITLANG.CNTL(SIEXCOB)'

