IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Calling REXX Load module from COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raam_kumar

New User


Joined: 25 Apr 2007
Posts: 44
Location: chennai, India

PostPosted: Tue Jun 05, 2007 1:51 pm
Reply with quote

Hi
I have written a sample rexx program and i have compiled it in to a load module. The code is shown below

ADDRESS ISPEXEC "CONTROL ERRORS RETURN"
ADDRESS ISPEXEC "VGET (NAME) SHARED"
say 'return code is' rc
say zerrlm
IF RC > 0 THEN DO
SAY "E -> VGET FAILED FOR NAME. RC = "RC
SAY STRIP(ZERRLM)
END
say 'hi'
say 'This is' NAME
say 'Bye'
exit
(i have compiled this code and created a load module as XXXX)
Now my requirement is to call this compiled rexx code from COBOL program. While executing this rexx routine it has to get the value for the field name from COBOL and display it in spool. Can any one help me in doing this
Back to top
View user's profile Send private message
TG Murphy

Active User


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

PostPosted: Thu Jun 07, 2007 1:12 am
Reply with quote

This probably doesn't answer your question but just in case...

I have never used the REXX compiler. We don't compile any of our Rexx stuff - we just execute it using the Rexx interpreter. I know the compiler exists from the REXX manuals. So we have no load module - as a result I have no idea how to answer your question.

I'm guessing you already know that you can run Rexx without a load module. However, if not, then now you know. So perhaps running your Rexx in interpreted mode is your solution.

Sorry could not be of better help - I noticed that nobody could answer your question (neither could I) so thought I would mention the interpreter.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Thu Jun 07, 2007 1:17 am
Reply with quote

Same situation here. I can only presume that compiled REXX would be called from a COBOL program like any other compiled program, but I don't know that for a fact.

What I don't get is why bother? The REXX code shown isn't really doing anything that the COBOL program couldn't be doing itself (a VGET of a variable from the ISPF variable pool). I can only presume that this is an exercise.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 07, 2007 1:42 am
Reply with quote

Hello,

Methinks this is a learning exercise to reslove the COBOL/REXX interaction with "play" code before trying to implement a solution that might be promoted to general use. . .
Back to top
View user's profile Send private message
raam_kumar

New User


Joined: 25 Apr 2007
Posts: 44
Location: chennai, India

PostPosted: Fri Jun 08, 2007 9:42 am
Reply with quote

Hello all
As Dick Scherrer said. This is a learning exercise before implementing it for a particular requirement.
I have been a bit successful in my path until now. I have successfully compiled the REXX routine and i am able to call it throuch cobol program. But the problem i am facing is, i am not able to pass the value to the variables. For Eg.
I have used CALL <REXX LOAD NAME> using Variable name

The rexx program gets called and the above mentioed statements gets executed. But the variable (NAME) is not getting its correct value. it just displays as NAME only. Can any one help me on that
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jun 08, 2007 1:27 pm
Reply with quote

Hello,

How difficult would it be to test your process calling a COBOL program (ihnstead of REXCX) and displaying the variable?

It almost sounds like the "using Variable name" is pointing to the literal of the field name rather than content.
Back to top
View user's profile Send private message
raam_kumar

New User


Joined: 25 Apr 2007
Posts: 44
Location: chennai, India

PostPosted: Fri Jun 08, 2007 6:14 pm
Reply with quote

Hello

My requirement is as follows.

I need to read a ps file. Deponding upon some condition i need to obtain a value from particular position and generate random numbers. I also know that there is a "RANDOM" function in COBOL which will do the same. But the small disadvantage is, for particular input the output of this function is constant. (for eg: if i give 39 as input i get 722 as output. Next time i give 39 as input i get 722 as output) But the requierment is the random number generated every time should be different (irrespective of same input 'n' no. of times). We have a rexx routine which does this functionality (i.e if i give '39' for first time it gies 722 and next time when i give '39' as input i get different number).
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jun 08, 2007 6:58 pm
Reply with quote

Hello,

My bad - i didn't explain the previous reply very well.

I'm not suggesting to use COBOL instead of REXX. I was just thinking that testing COBOL to COBOL would prove that the calling program was passing info correctly.

If the COBOL to COBOL has the same problem, the change will be needed in the calling program. If COBOL to COBOL is successful, the REXX code needs work.
Back to top
View user's profile Send private message
TG Murphy

Active User


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

PostPosted: Fri Jun 08, 2007 11:31 pm
Reply with quote

Raam,

If you do not find out how to pass the variable using the USING then consider using the program stack. The following code shows how to do a PULL. You should be able to modify without too much trouble to do a PUSH. Your COBOL program pushes the stack item and your REXX pulls it.


01 WS-IRXSTK PIC X(008) VALUE "IRXSTK".

*----------------------------------------------------------------
* Parms for IRXSTK (Retrieves data from the stack)
*----------------------------------------------------------------
01 WS-STACK-OP PIC X(008) VALUE "PULL ".
01 WS-STACK-ITEM-POINTER USAGE IS POINTER.
01 WS-STACK-ITEM-LENGTH PIC S9(9) BINARY.
01 WS-RET-CODE-IRXSTK PIC S9(9) BINARY.
01 WS-RELOC-ROUT PIC S9(9) BINARY.
01 WS-RELOC-RET PIC S9(9) BINARY.



420-PULL-FROM-STACK SECTION.
*---------------------------------------------------------------
* The REXX procedure will return 1 item on the STACK.
* Use the STACK "PULL" command to obtain this item.
*---------------------------------------------------------------
CALL WS-IRXSTK USING WS-STACK-OP
WS-STACK-ITEM-POINTER
WS-STACK-ITEM-LENGTH
WS-RET-CODE-IRXSTK
WS-RELOC-ROUT
WS-RELOC-RET
EVALUATE TRUE
WHEN RETURN-CODE = 0
SET WS-STACK-NOT-EMPTY TO TRUE
WHEN RETURN-CODE = 4
SET WS-STACK-IS-EMPTY TO TRUE
WHEN OTHER
GO TO E130-SERIOUS-STACK-ERROR
END-EVALUATE
.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Load new table with Old unload - DB2 DB2 6
Search our Forums:

Back to Top