View previous topic :: View next topic |
Author |
Message |
chandrasekhar.a Beginner
Joined: 05 Apr 2006 Posts: 7 Topics: 3
|
Posted: Tue Sep 11, 2007 3:23 pm Post subject: Calling external C program from rexx |
|
|
Hi,
I am trying to call a 'C' program from rexx. I am writing code both for the 'C' program and the rexx program and the example quoted here just describes the problem I am facing but not the complete reasons behind choosing this way. But this is the way I was supposed to do based on architechtural direction.
Here is the code I used to call the 'C' program from rexx.
MyVar = "xxxxxx";
ADDRESS LINKMVS "CHGSTR MyVar";
My requirement is to return a string from the 'C' program. Inorder to do that I am passing a string and try to update it in the 'C' program. Based on the notes I found in the reference manual(see below), any updates to this string (MyVar) should be present in the variable(MyVar) after the control comes back to the rexx program.
In my 'C' program I actual get the reference of the string and I am just chaging the chars present in the string. When I display it in 'C' program it shows as 'yyyyyy' (I displayed the reference of the string before and after changing its value and both are same, which ensures that I didnt do anything wrong in my C program). But when I display it in rexx, it is still 'xxxxxx'.
Why is the value changed in my 'C' program not reflecting back in my rexx program? If there any other way to have a string returned from the 'C' program to my 'rexx' program pls feel free to propose the idea.
Notes from the REXX/MVS reference manual.
As an example, suppose you link to a program called PGMCODES and pass a variable pcode that has the value PC7177. The LINKMVS environment evaluates the value of the variable pcode (PC7177) and builds a parameter list pointing to the value. The halfword length field contains the length of the value, which is 6, followed by the value itself. Suppose the PGMCODES program updates the PC7177 value to the value PC7177ADC3. When the PGMCODES program returns control to the LINKMVS environment, the program must update the length value in the halfword length field to 10 to indicate the actual length of the value it is returning to the exec.
If the value in the length field is greater than 0, the LINKMVS or ATTCHMVS environment updates the variable for that parameter with the value the program returned in the parameter list. If the length field is a positive number, LINKMVS or ATTCHMVS simply updates the variable using the length in the length field.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ2A304/2.6.9.2?SHELF=&DT=19951106081441
Thanks,
Chandra[/url] |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Sep 12, 2007 8:28 am Post subject: |
|
|
chandrasekhar.a,
AFAIK you need to link edit your C load module explicitly with the language entry module CEESTART to be able to invoke it from rexx
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
chandrasekhar.a Beginner
Joined: 05 Apr 2006 Posts: 7 Topics: 3
|
Posted: Wed Sep 12, 2007 9:17 am Post subject: |
|
|
I already have CEESTART in my jcl...pls see below....
Code: |
//BIND1 EXEC CBCCB,
// CPARM='OPTFILE(DD:OPTIONS)',
// BPARM='CALL,DYNAM(DLL)',STDLIBSD='C128N',
// OUTFILE='MY.LOADLIB,DISP=SHR'
//*LKED.SYSLIB DD DSN=ISP.SISPLOAD,DISP=SHR
//COMPILE.SYSIN DD DSN=MY.REXX(CHGSTR)
//OPTIONS DD DSN=ETPDBKQ.JOZEF.CTL(OPTBSYCC),DISP=SH
//BIND.IMPORT DD DSN=ETPDBKQ.JOZEF.IMPORT,DISP=SHR
// DD DSN=ISP.SISPLOAD,DISP=SHR
//BIND.SYSIN DD *
INCLUDE IMPORT(SDLIBC)
INCLUDE IMPORT(SDSYSLOG)
INCLUDE IMPORT(ISPEXEC)
ENTRY CEESTART
NAME CHGSTR(R)
/*
//* |
|
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Sep 12, 2007 9:22 am Post subject: |
|
|
chandrasekhar.a,
The C load module needs to be link edited with CEESTART.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
chandrasekhar.a Beginner
Joined: 05 Apr 2006 Posts: 7 Topics: 3
|
Posted: Wed Sep 12, 2007 9:29 am Post subject: |
|
|
I am sorry CHGSTR is a "C" program. The library is named as MY.REXX , but it is infact a C program. By the way we are able to invoke "C" program from rexx with some parameters and we are able to display them in "C" program but we are not able to get the updated parameter back.
Also, just for an example say it is a COBOL program instead of "C" program. Does this make it any easy to be called from REXX and update the passed string as discussed previously.
How about calling 'C' program from COBOL? I believe programs like BPXWDYN are written in 'C' language and we call them from COBOL and this program updates the parameters sent to it.
I am just trying to find out the similiarties involved. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Sep 12, 2007 10:07 am Post subject: |
|
|
chandrasekhar.a,
Just curious are you using RESULT keyword on your call statement in rexx? In cobol you use RETURNING verb to get back the results from the subroutine. Here is an example of COBOL program calling C/C++ functions
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
ramesh_v_s Beginner
Joined: 14 Oct 2004 Posts: 6 Topics: 3
|
Posted: Wed Sep 12, 2007 10:19 am Post subject: |
|
|
Hi Kolusu,
I am working with Chandra on this.
We are not using the CALL statement in rexx instead we are using LINKMVS and here is the syntax
ADDRESS LINKMVS "CHGSTR MYVAR"
Here MYVAR is having the value we are passing to the C program. We have kept displays in the C program for this and are getting that as argv[1].
We looked at LINKMVS manual and it says that the output will be returned from C program through this variable itself. So we updated address of argv[1] with what we are expecting to get back, we could see that argv[1] is getting updated but the output is not getting reflected back into my REXX.
Are you suggesting any better way to get this done than LINKMVS.
Thanks
Ramesh. |
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Wed Sep 12, 2007 11:43 am Post subject: |
|
|
Since you appear to have ISPF available, you can use VPUT and VGET services to do the information transfer. However, to do so, you must use the ISPEXEC SELECT PGM(....) invocation rather than a direct call. search for these on this board or Google for examples. It is a frequent request. |
|
Back to top |
|
 |
ramesh_v_s Beginner
Joined: 14 Oct 2004 Posts: 6 Topics: 3
|
Posted: Wed Sep 12, 2007 1:18 pm Post subject: |
|
|
Hi Semi,
I am having ISPF services. But when I try to use those with C I am not finding much help. I guess we need to use extern from C to interact with ISPF. I tried in this board and google but could not get any exmaples with C. Do you have any references where I can look for these.
Thanks
Ramesh. |
|
Back to top |
|
 |
|
|