structures, COBOL programming language" /> Structures
Home

 

Structures

In the COPY file, each structure declaration begins with a level-10 item; this enables you to declare several instances of the structure by coding the level-01 declaration and then using the COPY statement to copy in the remainder of the structure declaration. To refer to the appropriate instance, use the IN keyword:

* Declare two instances of MQMD
 01  MY-MQMD.
     COPY CMQMDV.
 01  MY-OTHER-MQMD.
     COPY CMQMDV.
*
* Set MSGTYPE field in MY-OTHER-MQMD
     MOVE MQMT-REQUEST TO MQMD-MSGTYPE IN MY-OTHER-MQMD.

Align the structures on appropriate boundaries. If you use the COPY statement to include a structure following an item that is not the level-01 item, ensure that the structure begins at the appropriate offset from the start of the level-01 item. Most MQI structures require 4-byte alignment; the exceptions to this are MQCNO, MQOD, and MQPMO, which require 16-byte alignment on i5/OS.

In this book, the names of fields in structures are shown without a prefix. In COBOL, the field names are prefixed with the name of the structure followed by a hyphen. However, if the structure name ends with a numeric digit, indicating that the structure is a second or later version of the original structure, the numeric digit is omitted from the prefix. Field names in COBOL are shown in uppercase (although lowercase or mixed case can be used if required). For example, the field MsgType described in MQMD - Message descriptor becomes MQMD-MSGTYPE in COBOL.

The V-suffix structures are declared with initial values for all the fields; we need to set only those fields where you want a value that is different from the supplied initial value.



 

Home