Preparing COBOL programs
WebSphere MQ for iSeries provides two methods for accessing the MQI from within COBOL programs:
- A dynamic call interface to programs having the names of the MQI functions,
such as MQCONN and MQOPEN. This interface is intended primarily for use with
the OPM (Original Program Mode) COBOL compiler, but can also be used with
the ILE (Integrated Language Environment(R)) COBOL compiler. Some
functions in WebSphere MQ for iSeries, such as MQCMIT and MQBACK, are not supported through
this interface, which is provided for compatibility with previous releases.
- A bound procedural call interface provided by service programs. This provides
access to all the MQI functions in WebSphere MQ for iSeries, support for threaded applications,
and potentially better performance than the dynamic call interface. This interface
can be used only with the ILE COBOL compiler.
In both cases the standard COBOL CALL syntax is used to access the MQI
functions.
The COBOL copy files containing the named constants and structure definitions
for use with the MQI are contained in the source physical files QMQM/QLBLSRC
and QMQM/QCBLLESRC. The members in these two files are identical, but are
packaged twice in this way to correspond with the defaults assumed by the
OPM and ILE COBOL compilers respectively.
The COBOL copy files use the single quotation mark character (') as the
string delimiter. The i5/OS COBOL compilers assume that the delimiter
is the double quote("). To prevent the compilers generating warning messages,
specify OPTION(*APOST) on the commands CRTCBLPGM, CRTBNDCBL, or CRTCBLMOD.
To make the compiler accept the single quotation mark character (') as
the string delimiter in the COBOL copy files, use the compiler option \APOST.
Using the dynamic call interface
- The QMQM library must be in your library list when you compile and when
you run COBOL programs using the MQI dynamic call interface.
- Use the CRTCBLPGM command to invoke the OPM COBOL compiler.
- Use either the CRTBNDCBL command or the two separate commands CRTCBLMOD
and CRTPGM to invoke the ILE COBOL compiler.
Using the bound procedure call interface
- First create a module using the CRTCBLMOD compiler specifying the parameter:
LINKLIT(*PRC)
- Then use the CRTPGM command to create the program object specifying the
parameter:
for non-threaded applications
BNDSRVPGM(QMQM/AMQ0STUB)
for threaded applications
BNDSRVPGM(QMQM/AMQ0STUB_R)
Note:
Except for programs created using the V4R4 ILE COBOL compiler
and containing the THREAD(SERIALIZE) option in the PROCESS statement, COBOL
programs must not use the threaded WebSphere MQ libraries. Even if a COBOL program
has been made thread safe in this manner, be careful when you design the application,
because THREAD(SERIALIZE) forces serialization of COBOL procedures at the
module level and might have an impact on overall performance.
See the iSeries(TM) WebSphere Development Studio: ILE COBOL Programmer's Guide and the iSeries WebSphere Development Studio: ILE COBOL Reference for further information.
For more information on compiling a CICS(R) application, see the CICS for AS/400 Application Programming Guide, SC41-5454.