Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

CAlling REXX from COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
teethu thomas

New User


Joined: 17 May 2007
Posts: 24
Location: India

PostPosted: Wed Sep 12, 2007 1:47 pm    Post subject: CAlling REXX from COBOL
Reply with quote

Hi,

Can anybody provide me with a sample code for calling REXX from COBOL.

If possible also give a description about the interface programs
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Sep 12, 2007 6:52 pm    Post subject: Reply to: CAlling REXX from COBOL
Reply with quote

COBOL Program:

Code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. COBREXX.
       INSTALLATION.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.

       DATA DIVISION.
       FILE SECTION.

       WORKING-STORAGE SECTION.
       01  ARGUMENT.
           03 ARG-SIZE        PIC 9(3) COMP.
           03 ARG-CHAR        PIC X(256).

       77  PGM-NAME           PIC X(8).

       PROCEDURE DIVISION.
           MOVE 'COBREXX  10' TO ARG-CHAR.
           MOVE 11            TO ARG-SIZE.
           MOVE 'IRXJCL'      TO PGM-NAME.
           CALL PGM-NAME USING ARGUMENT.
           DISPLAY 'RETURN-CODE=' RETURN-CODE.
           MOVE ZEROS TO RETURN-CODE.
           STOP RUN.


REXX Exec COBREXX:

Code:

/* REXX */
PARSE SOURCE SRC
ARG N
SAY "I AM" SRC
SAY "RECEIVED PARM" N
IF N = "" THEN N = 1
DO I = 1 TO N
  SAY "LOOP TIME" I
END
RETURN N
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Thu Sep 13, 2007 12:32 am    Post subject:
Reply with quote

The version I have here looks very much like the one provided by SuperK. Our version also includes a call to IKJTSOEV to create a TSO environment before the actual call to REXX happens.

If your REXX program needs to use TSO services I'm pretty sure you need the call to IKJTSOEV. SuperK - correct me if I'm wrong - not 100% sure on this...

My version also differs in another way. When I wrote this thing I had trouble accessing return parameters that REXX passes back to COBOL.

Rexx programs can optionally return data to the calling COBOL program. I was unable to make this work so I settled on the following ugly workaround. If the REXX program wants to pass data back to COBOL - it needs to do so by pushing something onto the program stack and not by using the standard way: RETURN something. Thus, my COBOL utility also calls IRXSTK to retrieve the data from the stack.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Thu Sep 13, 2007 1:40 am    Post subject: Reply to: CAlling REXX from COBOL
Reply with quote

This IBM site titled Calling REXX from COBOL contains a link to a downloadable document that contains two examples of calling REXX from COBOL - one that uses IRXJCL and one that uses IRXEXEC, and describes which one to use for which conditions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us