I have been trying to invoke a Cobol program from C program. I was able to call Cobol from C program perfectly but my cobol source inturn does a STATIC call to external lib routine. There it actually abends, in many sites they say it as some library missing in link-edit step but am able to run the Cobol as a stand alone ( executes external lib routine also) but when i invoke the same Cobol from C it just abends with SOC1.
Find below the JCL snippet i used for compile, Prelink and Link-edit
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
You need to post any informational/disgnostic information presented by either of the compiles or the link edits. You also need to post the disgnostic information from the abended run as well as the execute jcl.
When posting this information be sure to include thd message ids along with the message text. Please ust copy/paste and the "Code" tag for posting your info.
It sounds like the C program is calling the "wrong" version of the cobol
program. As you are using static calls, you may want to recompile/link all of the modules from the bottom up.
Find below the Abend dump which shows call chain it abends ( widh SOC1 ) where i have the CALL statement the subprogram is inturn a C program.
So my total flow of execution of load module (MVSC2COB) would be :
My C pgm -> My COBOL pgm (BITSCOB) ->C extern lib routine.
Code:
z/OS Language Environment V1 R8
Current and initial condition information is not available.
Load module MVSC2COB - cannot identify link date/library
(IDR information not available)
Call chain (Top 3 user levels in chain of 8)
Program Language Last executed statement
C failed with Abend Code S0C1 at
address 00000000
BITSCOB Cobol/zOS called C from offset 3D2
MVSC2COB called BITSCOB from
address 10000166 MVSC2COB + X'166'
My JESMSGLG for the submitted Runjcl :
Code:
IEA995I SYMPTOM DUMP OUTPUT 412
SYSTEM COMPLETION CODE=0C1 REASON CODE=00000001
TIME=11.01.26 SEQ=00676 CPU=0000 ASID=00A8
PSW AT TIME OF ERROR 078D1400 80000002 ILC 2 INTC 01
NO ACTIVE MODULE FOUND
NAME=UNKNOWN
Note : Am able to succesfully invoke the static call when i run my COBOL as a stand alone. Am confused why am not able to make it when i run the same cobol pgm thorugh C program.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
Sriram: have you read z/OS Language Environment Writing Interlanguage
Communication Applications, Document Number SA22-7563? Chapter 4.8 of this manual has an example of a C main program calling a COBOL subroutine calling a C subroutine, which sounds close to what you're doing.
One note: your EXTMETHOD cannot have a MAIN() declared in it. The chapter 4.8 C called subroutine does not have main.
But still am not able to get this through. Getting same SOC1 abend
I changed my Linkedit statements like :
Code:
INCLUDE SYSLIB(CEEROOTB)
INCLUDE SYSLIB(CSQBSTUB) -> MQstub
INCLUDE SYSLIB(BMWBSTUB) -> external lib stub
INCLUDE SYSLIB(EDCSTART)
INCLUDE SYSLIB(@@CBL2C) -> for making cobol to C communication
INCLUDE SYSLIB(@@C2CBL) -> for making C to cobol communication
INCLUDE SYSLIB(BITSCOB) -> Object module for Cobol
INCLUDE SYSLIB(MVS2CSAM) -> Object module for C
NAME MVSC2COB(R)
As you can see my JCL from above posts:
What am actually doing in my JCL (compile, Prelink, Link-edit) :
step 1: compiling C pgm and obtain Object module
step 2: compile Cobol pgm and obtain Cobol object and catalogue
step 3: link-edit both the object module and include all the private libs
as mentioned above.
Now newly i have included
Code:
INCLUDE SYSLIB(@@C2CBL)
yet no luck.
I did find a C program having VOID MAIN () calling COBOL routine. So its really same am doing and whatever mentioned in the document i have done it. But really can't find out where the error is. Pls assist me on this.
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
Sriram, you keep focusing on your C main program and the COBOL routine. They don't appear to be your problem; the problem is whatever EXTMETHOD is and how it relates to COBOL and C. Since you said the COBOL program can call EXTMETHOD without a problem if the COBOL program is the main routine, it appears that introducing the C environment is where the problem comes from. You might try having the C program directly call EXTMETHOD to see if there's a problem. Otherwise, you're probably going to have to find out where EXTMETHOD came from and talk to the vendor who supplied it to find out why your program is not working the way you've coded it.
You may have to give up on the idea of having a C main program and use the COBOL program to drive the work, since that appears to be the only way it has worked so far.