Start of change

Using a sender copy message to obtain a reply

This topic describes how to obtain a reply to an inquiry message by using a sender copy message.

When an inquiry message is sent it expects a reply. To allow the sender of an inquiry message to obtain a reply, a sender copy message is issued and associated internally with the inquiry message. A sender copy message is a copy of the inquiry message that is used by the sender to obtain the reply that was sent to its associated inquiry message. Sending and inquiry and obtaining the reply can be done rather easily when using the SNDUSRMSG command in a program or procedure. If the SNDUSRMSG command is not used, the function to send an inquiry and obtain the reply can be done by the SNDPGMMSG and RCVMSG commands in a program or procedure. An inquiry can be sent with the SNDPGMMSG command and the reply can be obtained using the RCVMSG command. For example, when an inquiry message is sent with the SNDPGMMSG command, the message reference key (MRK) of the sender copy can be returned on the SNDPGMMSG command on the KEYVAR parameter. The sender copy message is placed on the reply message queue that is specified on the SNDPGMMSG command. When a reply is sent to the inquiry message, internal message handling will also send the same reply to the sender copy message. Then the program can obtain the reply with RCVMSG by doing the following:

Related tasks
Example: Send an immediate message and handling a reply
Related reference
Examples: Send messages
End of change