Coding in COBOL
Note the information in the following section when coding IBM® MQ programs in COBOL.
Named constants
The names of constants are shown containing the underscore character (_) as part of the name. In COBOL, you must use the hyphen character (-) in place of the underscore. Constants that have character-string values use the single quotation mark character (') as the string delimiter. To make the compiler accept this character, use the compiler option APOST.
The copy file CMQV contains declarations of the named constants as level-10 items. To use the constants, declare the level-01 item explicitly, then use the COPY statement to copy in the declarations of the constants:
WORKING-STORAGE SECTION.
01 MQM-CONSTANTS.
COPY CMQV.
However, this method causes the constants to occupy storage in the program even if they are not referred to. If the constants are included in many separate programs within the same run unit, multiple copies of the constants will exist; this might result in a significant amount of main storage being used. You can avoid this by adding the GLOBAL clause to the level-01 declaration:
* Declare a global structure to hold the constants
01 MQM-CONSTANTS GLOBAL.
COPY CMQV.
This allocates storage for only one set of constants within the run unit; the constants, however, can be referred to by any program within the run unit, not just the program that contains the level-01 declaration.
Ensuring structure alignment
Care should be taken to ensure IBM MQ structures that are passed on to start on the MQ call's must be aligned on word boundaries. A word boundary is 4 bytes for 32-bit processes, 8 bytes for 64 bit processes and 16 bytes for 128 bit processes ( IBM i ).
Where possible, place all IBM MQ structures together so they are all boundary aligned.