Overview for MQCHARV

Availability: The MQCHARV structure is available on the following platforms:

  • AIX
  • IBM i
  • Linux
  • Windows

and for IBM MQ MQI clients connected to these systems.

Purpose: Use the MQCHARV structure to describe a variable length string.

Character set and encoding: Data in the MQCHARV must be in the encoding of the local queue manager that is given by MQENC_NATIVE and the character set of the VSCCSID field within the structure. If the application is running as an MQ client, the structure must be in the encoding of the client. Some character sets have a representation that depends on the encoding. If VSCCSID is one of these character sets, the encoding used is the same encoding as that of the other fields in the MQCHARV. The character set identified by VSCCSID can be a double-byte character set (DBCS).

Usage: The MQCHARV structure addresses data that might be discontiguous with the structure containing it. To address this data, fields declared with the pointer data type can be used. Be aware that COBOL does not support the pointer data type in all environments. Because of this, the data can also be addressed using fields that contain the offset of the data from the start of the structure containing the MQCHARV.


COBOL programming

To port an application between environments, we must ascertain whether the pointer data type is available in all the intended environments. If not, the application must address the data using the offset fields instead of the pointer fields.

In those environments where pointers are not supported, we can declare the pointer fields as byte strings of the appropriate length, with the initial value being the all-null byte string. Do not alter this initial value if we are using the offset fields. One way to do this without changing the supplied copy books is to use the following:

COPY CMQCHRVV REPLACING POINTER BY ==BINARY PIC S9(9)==.

where CMQCHRVV can be exchanged for the copy book to be used.

Parent topic: MQCHARV - Variable Length String