- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Calling COBOL sub-program from C
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2006 04:24 AM
тАО10-07-2006 04:24 AM
I need to call Cobol sub-program from C.
As I'm not an Cobolexpert I have 2 questions:
1. Is there any specific COBOL initialisation run time routine to call from the C progam (like you have to do for C when C is not the main program)?
2. The C main program need to pass some string using a descriptor, the length of the string may vary, how to declare this in the COBOL sub-program?
Thanks,
JF
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2006 06:04 AM
тАО10-07-2006 06:04 AM
Solution"HP COBOL User Manual"?
http://h71000.www7.hp.com/doc/82final/6297/6297pro.html
In particular, Chapter 12, "Interprogram
Communication":
http://h71000.www7.hp.com/doc/82final/6297/6297pro_088.html#interpro_com_chap
specifically Section 12.6, "Calling HP COBOL
Programs from Other Languages (Alpha, I64)":
http://h71000.www7.hp.com/doc/82final/6297/6297pro_092.html#other_lang_sec
Chpater 13 seems to cover going in the other
direction, too.
If the COBOL subprogram already exists,
wouldn't you want to write the C code to
accomodate the existing COBOL
argument-passing method, rather than
changing the declarations in the COBOL
subprogram? (And if the COBOL subprogram
does not already exist, why would you be
writing it COBOL?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2006 02:34 PM
тАО10-07-2006 02:34 PM
Re: Calling COBOL sub-program from C
1) Cobol use LIB$INITIALIZE, but I believe that will all happen automagically at image activation following magic psect contribution. No need for a caller to prep.
2) Cobol itself basically (sic) only works with fixed length strings. And program parameters, described in the LINKAGE SECTION, must all be passed by reference.
Of course one can play games and call passing a descriptor, but receiving it as a reference to a descriptor structure, which gives access to length, type, address.
If you are still at freedom to define your parameters then do the cobol folks a favor and you just pass a reference to the string (address of first byt) and seperately the address of an int holding the length.
On the cobol side you'll want to look at "refence modification" and STRING or INSPECT (if you opt for null terminated strings).
Check out some of (my) examples in topic 1052374
( http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1052374 )
Hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2006 09:58 PM
тАО10-07-2006 09:58 PM
Re: Calling COBOL sub-program from C
Thanks for the pointer. I had take a look at the documentation "HP COBOL User Manual" but probably too quickly because I have miss section 12.6 which is what I'm looking for.
The program COBOL exist as a program, but not as a subprogram so a rewrite in C is not a option but update are required.
JF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2006 10:09 PM
тАО10-07-2006 10:09 PM
Re: Calling COBOL sub-program from C
merci pour la reponse.
Thanks for the example reference, would be very useful.
As the COBOL parameters are not, currently, defined I will follow your advise and split the descriptors (dynamic string) in two part (length and string pointer). Seem to be the best option.
The last time I have wrote a COBOL program was probably 25 years ago...
Thanks again,
JF