You can run an ILE COBOL program by calling it from another HLL program.
You can use the ILE COBOL CALL statement in a ILE COBOL program to call another ILE COBOL program. If the ILE COBOL call is a dynamic program call, the program object can be library qualified by using the IN LIBRARY phrase. For example, to call program object PGMNAME in library LIBNAME, you would specify:
CALL "PGMNAME" IN LIBRARY "LIBNAME" USING variable1.
Without the IN LIBRARY phrase, a program object is found by searching the library list *LIBL. See the "CALL Statement" section of the WebSphere Development Studio: ILE COBOL Reference for more information.
To run an ILE COBOL program from ILE C, use an ILE C function call. The name of the function corresponds to the name of the ILE COBOL program. By default, this function call is a static procedure call. To perform a dynamic program call, use the #pragma linkage (PGMNAME, OS) directive. PGMNAME represents the name of the ILE COBOL program that you want to run from the ILE C program. Once you have used the #pragma linkage (PGMNAME, OS) directive to tell the ILE C compiler that PGMNAME is an external program, you can run your ILE COBOL program through an ILE C function call. For more information, refer to the chapter on writing programs that call other programs in the WebSphere Development Studio: ILE C/C++ Programmer's Guide.
To run an ILE COBOL program from an ILE RPG program, use the CALL operation code to make a dynamic program call or the CALLB operation code to make a static procedure call. You identify the program to be called by specifying its name as the Factor 2 entry. For more information, refer to the chapter on calling programs and procedures in the WebSphere Development Studio: ILE RPG Programmer's Guide.
To run an ILE COBOL program from C++, use a C++ function call. The name of the function corresponds to the name of the ILE COBOL program. To prevent C++ from internally changing the name of the function, that is to prevent the VisualAge(R) C++ function name from mangling, you must prototype the function call using the extern keyword. To call an ILE COBOL procedure that returns nothing, and takes one 2 byte binary number, the C++ prototype would be:
extern "COBOL" void PGMNAME(short int);
To call the same COBOL program object, you would specify a linkage of "OS". The prototype becomes:
extern "OS" void PGMNAME(short int);
A linkage of "COBOL" on a C++ function call not only prevents function name mangling but causes any arguments passed to the ILE COBOL procedure to be passed BY REFERENCE. If the ILE COBOL procedure is expecting a BY VALUE parameter then a linkage of "C" should be specified.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.