Parameters

Bag (MQHBAG) - input
Handle of the bag whose items are to be counted. This can be a user bag or a system bag.
Selector (MQLONG) - input
Selector of the data items to count.

If the selector is less than zero (a system selector), the selector must be one that is supported by the MQAI. MQRC_SELECTOR_NOT_SUPPORTED results if it is not.

If the specified selector is not present in the bag, the call succeeds and zero is returned for ItemCount.

The following special values can be specified for Selector:

MQSEL_ALL_SELECTORS
All user and system items are to be counted.
MQSEL_ALL_USER_SELECTORS
All user items are to be counted; system items are excluded from the count.
MQSEL_ALL_SYSTEM_SELECTORS
All system items are to be counted; user items are excluded from the count.

ItemCount (MQLONG) - output
Number of items of the specified type in the bag (can be zero).

CompCode (MQLONG) - output
Completion code.

Reason (MQLONG) - output
Reason code qualifying CompCode.

The following reason codes indicating error conditions can be returned from the mqCountItems call:

MQRC_HBAG_ERROR
Bag handle not valid.
MQRC_ITEM_COUNT_ERROR
ItemCount parameter not valid (invalid parameter address).
MQRC_SELECTOR_NOT_SUPPORTED
Specified system selector not supported by the MQAI.
MQRC_SELECTOR_OUT_OF_RANGE
Selector not within valid range for call.