Receiving messages and command responses

Messages are sent to an extended MCS console when the system issues the WTO and WTOR macros. A message data block (MDB) contains the message delivered to the extended console. If the message is too long for one MDB, the MDB prefix area contains a pointer to the next MDB, where the message text continues. If multiple messages are sent to an extended MCS console, they will be placed into separate MDBs, requiring the issuance of separate MCSOPMSG macros to retrieve them. You can code a loop around the MCSOPMSG invocation so that the macro can retrieve messages currently queued to the extended MCS console. Exit the loop when there are no more messages (MCSOPMSG RC=8,RSN=0).

Once the message ECB of the extended MCS console has been posted, you can receive messages, and free storage for new messages by issuing the MCSOPMSG macro with the REQUEST=GETMSG option. You can receive messages by specifying certain message types. The CMDRESP option of MCSOPMSG allows you to retrieve the following messages:
  • A command response (CMDRESP=YES)
  • An unsolicited message or DOM (CMDRESP=NO).

If you choose to receive a command response, you can further specify the message command and response token (CART), which associates a response with a command. You can also specify a CART with a mask. Both the CART and mask are user-defined values originally specified on the MGCRE macro. A CART allows you to specify your selection criteria when retrieving command responses. A mask is a value that is compared to a CART with the logical AND instruction to broaden that selection criteria. For example, if the CART value is STR10001, MCSOPMSG searches for messages only with a CART value of STR10001. If the mask is X'FFFFFFFF00000000', MCSOPMSG uses the logical AND instruction to compare the two values and use the result as the search criteria. In this case, MCSOPMSG retrieves any command responses having STR1 as the first four characters of the CART.

If you do not specify CMDRESP, MCSOPMSG retrieves the next message in the queue on a first-in first-out basis.

If processing is successful, MCSOPMSG returns an address in GPR1 and an ALET in AR1; the GPR1/AR1 pair contains the address of the MDB. User applications are expected to copy the MDB from the message data space. On the next invocation of MCSOPMSG, the MDB in the message data space is deleted and returned back to the system, and either the next MDB will be returned to the caller, or a return and reason code will be given indicating that no more MDBs are currently queued.

You can also specify how the extended MCS console receives messages by specifying the MSGDLVRY parameter on the MCSOPER macro. MSGDLVRY enables you to request messages on a first-in-first-out basis (MSGDLVRY=FIFO) or by search arguments (MSGDLVRY=SEARCH) that you specify on MCSOPMSG. You can also request that no messages be queued to the extended MCS console (MSGDLVRY=NONE).

You need to understand the structure of the MDB to retrieve the message from it.