+

Search Tips | Advanced Search

Preparing COBOL programs in IBM i

Learn about preparing COBOL programs in IBM i and the method of accessing the MQI from within the COBOL program.


About this task

For accessing the MQI from within COBOL programs, IBM MQ for IBM i provides a bound procedural call interface provided by service programs. This provides access to all the MQI functions in IBM MQ for IBM i and support for threaded applications. This interface can be used only with the ILE COBOL compiler.

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 file QMQM/QCBLLESRC.

The COBOL copy files use the single quotation mark character (') as the string delimiter. The IBM i COBOL compilers assume that the delimiter is the quotation mark ("). 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.

Note: The dynamic call interface is not provided in IBM MQ Version 9.0 or later.

To use the bound procedure call interface, complete the following steps.


Procedure

  1. Create a module using the CRTCBLMOD compiler specifying the parameter:
    LINKLIT(*PRC)
    
  2. Use the CRTPGM command to create the program object, specifying the appropriate parameter: For non-threaded applications:
    BNDSRVPGM(QMQM/AMQ0STUB)		Server for COBOL for non-threaded applications
    BNDSRVPGM(QMQM/AMQCSTUB)		Client for COBOL for non-threaded applications
    
    For threaded applications:
    BNDSRVPGM(QMQM/AMQ0STUB_R)		Server for COBOL for threaded applications
    BNDSRVPGM(QMQM/AMQCSTUB_R)		Client for COBOL for threaded applications
    
    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 IBM 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 affect overall performance.

    See the WebSphere Development Studio: ILE COBOL Programmer's Guide and the WebSphere Development Studio: ILE COBOL Reference for further information.

    For more information about compiling a CICS application, see the CICS for IBM i Application Programming Guide, SC41-5454.

Parent topic: Building your procedural application on IBM i

Last updated: 2020-10-04