例子轉自IBM z/OS V1R9.0 information center
//* -->uidIEC JOB - Specify your Job card here
//*-----------------------------------------------------------*
//*
//* Interlanguage Communication in z/OS
//* Calling REXX from COBOL
//*
//*-----------------------------------------------------------*
//*
//* Licensed Materials - Property of IBM
//* 5695-013
//* (C) Copyright IBM Corp. 1989, 2003
//*
//*-----------------------------------------------------------*
//* Sample JCL for calling IRXJCL from COBOL program.
//* For a description also refer to the REXX Compiler guide
//* SH19-8160.
//* You may modify this sample for your needs by including
//* a REXX of your own. The argument for the REXX procedure
//* may be taylored for your needs.
//*
//* Change Activity: 030708 - new for Release 4
//*-----------------------------------------------------------*
//* JCLLIB accesses the CLG procs, modify to your needs
//*-----------------------------------------------------------*
//*MYLIB JCLLIB ORDER=RXT.INTLANG.CNTL
//*-----------------------------------------------------------*
//* Create REXX procedure HELLO into a temporary Library &&REXX
//* SYSUT1 is setup for card input, modify to a DSN if desired.
//*-----------------------------------------------------------*
//CREATE EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT2 DD DSN=&&REXX(HELLO),DISP=(NEW,PASS),
// UNIT=SYSDA,SPACE=(TRK,(1,1,1)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PO)
//SYSUT1 DD *,DLM=$$
/* REXX - A simple exec ****************** Start sample exec */
Parse source src /* sample exec */
Arg n /* sample exec */
Say 'I am' src /* sample exec */
Say 'Received parm:' n /* sample exec */
If n='' Then n=1 /* sample exec */
Do i=1 TO n /* sample exec */
Say 'Hello World the' i'. time ...' /* sample exec */
End /* sample exec */
Return n /* Set Return Code to n */ /* sample exec */
/******************************************* End sample exec */
$$
//*-----------------------------------------------------------*
//* Compile, link and execute a COBOL program
//*-----------------------------------------------------------*
//* Invoke the cataloged procedure IGYWCLG to compile, link and
//* execute the below listed Cobol program.
//* The Cobol program below calls the above listed REXX sample
//* exec as stored in the temporary dataset using the
//* TSO service IRXJCL.
//*-----------------------------------------------------------*
//IGYWCLG EXEC IGYWCLG
//COBOL.SYSIN DD *
CBL NOADV,NODYN,NONAME,NONUMBER,QUOTE,SEQ,XREF,VBREF,DUMP,LIST
TITLE "COBOL TEST PROGRAM ".
Identification Division.
Program-id. COBPRG.
IA0040 Author. ...
*** **
*** Invoke REXX procedure HELLO with parameter 3 using IRXJCL **
*** **
*** Expected display messages: **
*** "PROGRAM CONPRG - BEGINNING" **
*** "PROGRAM COBPRG - NORMAL END" **
*** **
*****************************************************************
Environment division.
IA0970 Configuration section.
Special-names.
Input-output section.
File-control.
Select PRINT-FILE
assign to SYS014-S-UPDPRNT
file status is UPDPRINT-FILE-STATUS.
Data division.
File section.
IA1570 FD PRINT-FILE
recording mode F
block 0 records
record 121 characters
label record standard.
IA1620 01 print-record pic x(121).
Working-storage section.
01 Working-storage-for-COBPRG pic x.
01 ARGUMENT.
03 ARG-SIZE pic 9(2) comp.
03 ARG-CHAR pic x(8).
77 UPDPRINT-file-status pic xx.
77 PGM-NAME pic x(8).
/****************************************************************
*** D O M A I N L O G I C **
*****************************************************************
procedure division.
000-do-main-logic.
display "PROGRAM COBPRG - Beginning".
display "Return code before call is " RETURN-CODE.
*
* Pass the procedure pame HELLO to IRXJCL.
* Pass 3 to REXX procedure 'HELLO'.
* Set the size of the argument.
*
move "HELLO 3" to ARG-CHAR.
move 8 to arg-size.
* Call "IRXJCL" in order to execute the REXX procedure
move "IRXJCL" to PGM-NAME.
CALL PGM-NAME USING ARGUMENT.
* Display the return code.
display "Return code after call is " RETURN-CODE.
display "PROGRAM COBPRG - Normal end".
stop run.
IA9990 end program COBPRG.
/*
//*-----------------------------------------------------------*
//* Define the library containing the REXX exec
//*-----------------------------------------------------------*
//GO.SYSEXEC DD DISP=(SHR,PASS),DSN=&&REXX
//*-----------------------------------------------------------*
//* Next DD is the data set equivalent to terminal input
//*-----------------------------------------------------------*
//GO.SYSTSIN DD DUMMY
//*-----------------------------------------------------------*
//* Next DD is the data set equivalent to terminal output
//*-----------------------------------------------------------*
//GO.SYSTSPRT DD SYSOUT=*
//GO.SYSOUT DD SYSOUT=*
//*-----------------------------------------------------------*
//