MQBag properties

The properties of MQBag objects are explained over the following pages.

Item property

Purpose

It is used to set or inquire about the value of an item. Use of this property corresponds to the following MQAI calls:

in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Item (Selector, ItemIndex, Value)

Parameters

Selector  (VARIANT) - input 
Selector of the item to be set or inquired.

When inquiring about an item, MQSEL_ANY_USER_SELECTOR is the default. When setting an item, MQIA_LIST or MQCA_LIST is the default.

If the Selector is not of type long, MQRC_SELECTOR_TYPE_ERROR results.

This parameter is optional.

ItemIndex  (LONG) - input 
This value identifies the occurrence of the item of the specified selector that is to be set or inquired on. MQIND_NONE is the default.

This parameter is optional.

Value  (VARIANT) - input/output 
The value returned or the value to be set. When inquiring about an item, the return value can be of type long, string, or MQBag. However, when setting an item, the value must be of type long or string; if not, MQRC_ITEM_VALUE_ERROR results.
Note:
You must enter a value for either the Selector or ItemIndex parameter; if one is not present, MQRC_PARAMETER_MISSING results. Item Property is the default property for the MQBag class, so does not need to be explicitly coded.

Visual Basic Language Invocation

When inquiring about a value of an item within a bag:

Value = mqbag[.Item]([Selector],
[ItemIndex])

For MQBag references:

Set abag = mqbag[.Item]([Selector].
[ItemIndex])

To set the value of an item in a bag:

mqbag[.Item]([Selector],
[ItemIndex]) = Value

Count property

Purpose

within a bag. This property corresponds to the MQAI call, "mqCountItems," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Count (Selector, Value)

Parameters

Selector  (VARIANT) - input 
Selector of the data items to be included in the count.

MQSEL_ALL_USER_SELECTORS is the default.

If the Selector is not of type long, MQRC_SELECTOR_TYPE_ERROR is returned.

Value  (LONG) - output 
The number of items in the bag included by the Selector.

Visual Basic Language Invocation

To return the number of items in a bag:

ItemCount = mqbag.Count([Selector])

Options property

Purpose

bag. This property corresponds to the Options parameter of the MQAI call, "mqCreateBag," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Options (Options)

Parameters

Options  (LONG) - input/output 
The bag options.
Note:
The bag options must be set before data items are added to or set within the bag. If the options are changed when the bag is not empty, MQRC_OPTIONS_ERROR results. This applies even if the bag is subsequently cleared.

Visual Basic Language Invocation

When inquiring about the options of an item within a bag:

Options = mqbag.Options

To set an option of an item in a bag:

mqbag.Options = Options

MQBag methods

The methods of the MQBag objects are explained over the following pages.

Add method

Purpose

method corresponds to the MQAI calls, "mqAddInteger"and "mqAddString," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Add (Value, Selector)

Parameters

Value  (VARIANT) - input 
Integer or string value of the data item.

Selector  (VARIANT) - input 
Selector identifying the item to be added.

Depending on the type of Value, MQIA_LIST or MQCA_LIST is the default. If the Selector parameter is not of type long, MQRC_SELECTOR_TYPE_ERROR results.

Visual Basic Language Invocation

To add an item to a bag:

mqbag.Add(Value,[Selector])

AddInquiry method

Purpose

the attribute to be returned when an administration bag is sent to execute an INQUIRE command. This method corresponds to the MQAI call, "mqAddInquiry,", in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


AddInquiry (Inquiry)

Parameters

Inquiry  (LONG) - input 
Selector of the WebSphere MQ attribute to be returned by the INQUIRE administration command.

Visual Basic Language Invocation

To use the AddInquiry method:

mqbag.AddInquiry(Inquiry)

Clear method

Purpose

bag. This method corresponds to the MQAI call, "mqClearBag,", in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Clear

Visual Basic Language Invocation

To delete all data itmes from a bag:

mqbag.Clear

Execute method

Purpose

message to the command server and waits for any reply messages. This method corresponds to the MQAI call, "mqExecute,", in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Execute (QueueManager, Command, OptionsBag, RequestQ, ReplyQ, ReplyBag)

Parameter

QueueManager  (MQQueueManager) - input 
The queue manager to which the application is connected.

Command  (LONG) - input 
The command to be executed.

OptionsBag  (MQBag) - input 
The bag containing options that affect the processing of the call.

RequestQ  (MQQueue) - input 
The queue on which the administration command message will be placed.

ReplyQ  (MQQueue) - input 
The queue on which any reply messages are received.

ReplyBag  (MQBag) - output 
A bag reference containing data from reply messages.

Visual Basic Language Invocation

To send an administration command message and wait for any reply messages:

Set ReplyBag = mqbag.Execute(QueueManager, Command,

[OptionsBag],[RequestQ],[ReplyQ])

FromMessage method

Purpose

into a bag. This method corresponds to the MQAI call, "mqBufferToBag," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


FromMessage (Message, OptionsBag)

Parameters

Message  (MQMessage) - input 
The message containing the data to be converted.

OptionsBag  (MQBag) - input 
Options to control the processing of the call.

Visual Basic Language Invocation

To load data from a message into a bag:

mqbag.FromMessage(Message,[OptionsBag])

ItemType method

Purpose

a specified item in a bag. This method corresponds to the MQAI call, "mqInquireItemInfo," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


ItemType (Selector, ItemIndex, ItemType)

Parameters

Selector  (VARIANT) - input 
Selector identifying the item to be inquired.

MQSEL_ANY_USER_SELECTOR is the default. If the Selector parameter is not of type long, MQRC_SELECTOR_TYPE_ERROR results.

ItemIndex  (LONG) - input 
Index of items to be inquired.

MQIND_NONE is the default.

ItemType  (LONG) - output 
Datatype of the specified item.
Note:
Either the Selector parameter, ItemIndex parameter, or both must be specified. If neither parameter is present, MQRC_PARAMETER_MISSING results.

Visual Basic Language Invocation

To return the type of a value:

ItemType = mqbag.ItemType([Selector],
[ItemIndex])

Remove method

Purpose

This method corresponds to the MQAI call, "mqDeleteItem," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Remove (Selector, ItemIndex)

Parameters

Selector  (VARIANT) - input 
Selector identifying the item to be deleted.

MQSEL_ANY_USER_SELECTOR is the default. If the Selector parameter is not of type long, MQRC_SELECTOR_TYPE_ERROR results.

ItemIndex  (LONG) - input 
Index of the item to be deleted.

MQIND_NONE is the default.

Note:
Either the Selector parameter, ItemIndex parameter, or both must be specified. If neither parameter is present, MQRC_PARAMETER_MISSING results.

Visual Basic Language Invocation

To delete an item from a bag:

mqbag.Remove([Selector],[ItemIndex])

Selector method

Purpose

specified item within a bag. This method corresponds to the MQAI call, "mqInquireItemInfo," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Selector (Selector, ItemIndex, OutSelector)

Parameters

Selector  (VARIANT) - input 
Selector identifying the item to be inquired.

MQSEL_ANY_USER_SELECTOR is the default. If the Selector parameter is not of type long, MQRC_SELECTOR_TYPE_ERROR results.

ItemIndex  (LONG) - input 
Index of the item to be inquired.

MQIND_NONE is the default.

OutSelector  (VARIANT) - output 
Selector of the specified item.
Note:
Either the Selector parameter, ItemIndex parameter, or both must be specified. If neither parameter is present, MQRC_PARAMETER_MISSING results.

Visual Basic Language Invocation

To return the selector of an item:

OutSelector = mqbag.Selector([Selector],
[ItemIndex])

ToMessage method

Purpose

MQMessage object. The reference contains data from a bag. This method corresponds to the MQAI call, "mqBagToBuffer," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


ToMessage (OptionsBag, Message)

Parameters

OptionsBag  (MQBag) - input 
A bag containing options that control the processing of the method.

Message  (MQMessage) - output 
An MQMessage object reference containing data from the bag.

Visual Basic Language Invocation

To use the ToMessage Method:

Set Message = mqbag.ToMessage([OptionsBag])

Truncate method

Purpose

in a bag. This method corresponds to the MQAI call, "mqTruncateBag," in the WebSphere MQ Programmable Command Formats and Administration Interface.

Format


Truncate (ItemCount)

Parameters

ItemCount  (LONG) - input 
The number of user items to remain in the bag after truncation has occurred.

Visual Basic Language Invocation

To reduce the number of user items in a bag:

mqbag.Truncate(ItemCount)


© IBM Corporation 2002. All Rights Reserved