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

Calling COBOL program from REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
airan1981

New User


Joined: 11 Nov 2008
Posts: 6
Location: Bentonville, AR US

PostPosted: Sun Aug 09, 2009 3:31 am
Reply with quote

Hi,

I have a requirement where REXX calls a COBOL program and COBOL programs INTURNS calls COBOL.

I am able to call the COBOL program from REXX but the COBOL program which is called from REXX calls another COBOL program give me message "MODULE NOT FOUND" while making the call.

I used the LIBDEF command to define the LOADLIBs where my COBOL program is present.

DOes any body has idea how to resolve the issue?

I searched over the GOOGLE and found that i need to define my LOADLIB thru TSOLIB but this works in TSO/E ready environment. I don't know how to invoke it.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sun Aug 09, 2009 10:37 am
Reply with quote

What environment are you executing in?

The LIBDEF only works for ISPF service calls. If you require an ISPF environment then perhaps you can call the second cobol program through SELECT PGM( ).

If you run in a batch job, add your loadlib to the STEPLIB concatenation.
Back to top
View user's profile Send private message
airan1981

New User


Joined: 11 Nov 2008
Posts: 6
Location: Bentonville, AR US

PostPosted: Sun Aug 09, 2009 6:55 pm
Reply with quote

I am running in the iSPF environment. Thats why, i can not add the loadLIB of COBOL program called from the COBOL program via REXX. How can i use SELECT PGM() in REXX. Can you give me some example.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sun Aug 09, 2009 10:02 pm
Reply with quote

Try using the TSO CALL command instead of SELECT PGM.

Read the rexx reference manual for Address TSO and the TSO Commands Reference for the CALL command syntax.
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: Mon Aug 10, 2009 1:48 am
Reply with quote

Hello,

Suggest you ask a co-worker.

There are many qualified people on that system. . .
Back to top
View user's profile Send private message
airan1981

New User


Joined: 11 Nov 2008
Posts: 6
Location: Bentonville, AR US

PostPosted: Mon Aug 10, 2009 6:56 pm
Reply with quote

My cobol program is able to call the seocnd cobol program via REXX (Thru CALL and SELECT CMD()). But, I can not receive back the return value in the REXX. I can pass the PARM thru TSO CALL but i dont know how to receive it back.

When i display the variable which is being passed from the REXX to cobol gives me the same string passed after the call also. I tried to find out, if there is any problem with the cobol and Its working fine.

I think i need to do something additional to receive the return value back in my REXX.
Back to top
View user's profile Send private message
airan1981

New User


Joined: 11 Nov 2008
Posts: 6
Location: Bentonville, AR US

PostPosted: Mon Aug 10, 2009 7:26 pm
Reply with quote

The SELECT PGM() also gives the same problem like "MODULE NOT FOUND" SELECT CMD and TSO CALL is working fine but I am not able to receive back the result in the REXX.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Aug 11, 2009 2:02 am
Reply with quote

RC is a built-in variable that has the last return code.
Code:
/* REXX */                   
ADDRESS TSO                 
"CALL 'SYS1.LINKLIB(ISPQRY)'"
SAY 'Return Code='RC                 
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Aug 11, 2009 2:09 am
Reply with quote

You may want to change your COBOL program to use ISPF's VGET and VPUT services to share variables with the rexx program.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Tue Aug 11, 2009 2:10 am
Reply with quote

You know, your original post never mentioned that you wanted to call a COBOL program and then return results back to your calling REXX code. I've never done that process, so I don't know how exactly it would be done from within a TSO or ISPF address space. In a regular REXX exec running in batch (PGM=IRXJCL) you can use the ADDRESS LINKMVS command to do what you want. Since you're running these from within the ISPF address space, have you tried just using ISPF shared variables (i.e. using VPUT and VGET services) as a means of passing data back and forth?
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Tue Aug 11, 2009 2:19 am
Reply with quote

I had a similar experience.

I used the LINKPGM command to make the call, but it may not change what is required to receive a return value.

What I found was that the length of the LINKAGE section passed from the REXX is all that would be received regardless of what was defined in the COBOL program.

For example if I passed twenty bytes of data from REXX, I would only receive twenty bytes back even though the COBOL was returning forty bytes.

To remedy this I used the following:
LINKAGE = LEFT(LINKAGE,39,' ')||'0'

Forcing a non-space in the 40th position established the length I needed.

I was now able to receive all forty bytes from my COBOL.

This was my experience, I hope it works for you.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Aug 11, 2009 2:22 am
Reply with quote

see
ibmmainframes.com/viewtopic.php?t=25377&highlight=linkpgm
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 -> CLIST & REXX

 


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 Using API Gateway from CICS program CICS 0
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top