Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Calling COBOL program from REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Calling COBOL program from REXX
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

Senior Member


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

PostPosted: Sun Aug 09, 2009 10:37 am    Post subject: Reply to: Calling COBOL program from REXX
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    Post subject:
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

Senior Member


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

PostPosted: Sun Aug 09, 2009 10:02 pm    Post subject: Reply to: Calling COBOL program from REXX
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

Site Director


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

PostPosted: Mon Aug 10, 2009 1:48 am    Post subject:
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    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Tue Aug 11, 2009 2:02 am    Post subject: Reply to: Calling COBOL program from REXX
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

Senior Member


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

PostPosted: Tue Aug 11, 2009 2:09 am    Post subject: Reply to: Calling COBOL program from REXX
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

Moderator Team Head


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

PostPosted: Tue Aug 11, 2009 2:10 am    Post subject: Reply to: Calling COBOL program from REXX
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: 688
Location: Pennsylvania

PostPosted: Tue Aug 11, 2009 2:19 am    Post subject: Reply to: Calling COBOL program from REXX
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Aug 11, 2009 2:22 am    Post subject: Reply to: Calling COBOL program from REXX
Reply with quote

see
http://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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
This topic is locked: you cannot edit posts or make replies. Rexx to Grab ISMF Information. upendrasri All Other Mainframe Topics 16 Sun Nov 26, 2017 12:35 am
No new posts Rexx to send an email without SMTP Se... upendrasri All Other Mainframe Topics 12 Sun Nov 19, 2017 7:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us