mqBagToBuffer

The mqBagToBuffer call converts the bag into a PCF message in the supplied buffer.


Syntax for mqBagToBuffer

    mqBagToBuffer (OptionsBag, DataBag, BufferLength, Buffer, DataLength, CompCode, Reason)


Parameters for mqBagToBuffer

    OptionsBag (MQHBAG) - input
    Handle of the bag containing options that control the processing of the call. This is a reserved parameter; the value must be MQHB_NONE.

    DataBag (MQHBAG) - input
    The handle of the bag to convert.

    If the bag contains an administration message and mqAddInquiry was used to insert values into the bag, the value of the MQIASY_COMMAND data item must be an INQUIRE command that is recognized by the MQAI; MQRC_INQUIRY_COMMAND_ERROR results if it is not.

    If the bag contains nested system bags, MQRC_NESTED_BAG_NOT_SUPPORTED results.

    BufferLength (MQLONG) - input
    Length in bytes of the buffer supplied.

    If the buffer is too small to accommodate the message generated, MQRC_BUFFER_LENGTH_ERROR results.

    Buffer (MQBYTE x BufferLength) - output
    The buffer to hold the message.

    DataLength (MQLONG) - output
    The length in bytes of the buffer required to hold the entire bag. If the buffer is not long enough, the contents of the buffer are undefined but the DataLength is returned.

    CompCode (MQLONG) - output
    Completion code.

    Reason (MQLONG) - output
    Reason code qualifying CompCode. The following reason codes indicating error conditions can be returned from the mqBagToBuffer call:

      MQRC_BAG_WRONG_TYPE
      Input data bag is a group bag.

      MQRC_BUFFER_ERROR
      Buffer parameter not valid (invalid parameter address or buffer not accessible).

      MQRC_BUFFER_LENGTH_ERROR
      Buffer length not valid or buffer too small. (Required length returned in DataLength.)

      MQRC_DATA_LENGTH_ERROR
      DataLength parameter not valid (invalid parameter address).

      MQRC_HBAG_ERROR
      Bag handle not valid.

      MQRC_INQUIRY_COMMAND_ERROR
      mqAddInquiry used with a command code that is not recognized as an INQUIRE command.

      MQRC_NESTED_BAG_NOT_SUPPORTED
      Input data bag contains one or more nested system bags.

      MQRC_OPTIONS_ERROR
      Options bag contains unsupported data items or a supported option has an invalid value.

      MQRC_PARAMETER_MISSING
      An administration message requires a parameter that is not present in the bag. Note: This reason code occurs for bags created with the MQCBO_ADMIN_BAG or MQCBO_REORDER_AS_REQUIRED options only.

      MQRC_SELECTOR_WRONG_TYPE
      mqAddString or mqSetString was used to add the MQIACF_INQUIRY selector to the bag.

      MQRC_STORAGE_NOT_AVAILABLE
      Insufficient storage available.


Usage notes for mqBagToBuffer

  1. The PCF message is generated with an encoding of MQENC_NATIVE for the numeric data.
  2. The buffer that holds the message can be null if the BufferLength is zero. This is useful if we use the mqBagToBuffer call to calculate the size of buffer necessary to convert your bag.


C language invocation for mqBagToBuffer

mqBagToBuffer (OptionsBag, DataBag, BufferLength, Buffer, &DataLength,
&CompCode, &Reason);
Declare the parameters as follows:
MQHBAG  OptionsBag;     /* Options bag handle */
MQHBAG  DataBag;        /* Data bag handle */
MQLONG  BufferLength;   /* Buffer length */
MQBYTE  Buffer[n];      /* Buffer to contain PCF */
MQLONG  DataLength;     /* Length of PCF returned in buffer */
MQLONG  CompCode;       /* Completion code */
MQLONG  Reason;         /* Reason code qualifying CompCode */


Visual Basic invocation for mqBagToBuffer

(Supported on Windows only.)

mqBagToBuffer OptionsBag, DataBag, BufferLength, Buffer, DataLength,
CompCode, Reason
Declare the parameters as follows:
Dim OptionsBag   As Long 'Options bag handle'
Dim DataBag      As Long 'Data bag handle'
Dim BufferLength As Long 'Buffer length'
Dim Buffer       As Long 'Buffer to contain PCF'
Dim DataLength   As Long 'Length of PCF returned in buffer'
Dim CompCode     As Long 'Completion code'
Dim Reason       As Long 'Reason code qualifying CompCode'
Parent topic: MQAI calls