CL Command Reference - SNDUSRMSG

CL Command List > SNDUSRMSG Reference

Description:

The Send User Message (SNDUSRMSG) command is used by a program to send a message to a message queue and optionally receive a reply to that message. The message sent using this command can be either an impromptu or a predefined message and can be sent to a display station user in an interactive job or a specific message queue. For inquiry messages, a CL variable can be specified to receive the reply value, and the program using this command will wait for a response.

This command uses a combination of parameters available on the Send Program Message (SNDPGMMSG) and Receive Message (RCVMSG) commands to allow a program to send and receive messages by using a single command. Also, the SNDUSRMSG command provides validity checking and uppercase translation for replies to inquiry messages.

Restrictions:

1. The SNDUSRMSG command allows a message of up to 512 characters of first-level message text to be sent. However, if the message is sent to an external message queue (*EXT) in an interactive job, only 76 characters are shown on the Display Program Messages display. If the message is sent to a user¡¯s, work station¡¯s, or system operator¡¯s message queue, the Display Message (DSPMSG) command allows all 512 characters to be displayed.


Examples:

Example 1: Message Requiring Specific Reply

SNDUSRMSG MSG(¡¯Data verified. Update master files (Y,N)?¡¯)
TOMSGQ(*) VALUES(Y N) DFT(N) MSGRPY(&REPLY)

This command sends an inquiry message to the display station operator (if it is used in an interactive job) or to the system operator (if it is used in a batch job). The valid replies are Y and N, and any other reply is rejected. The reply is returned in the variable &REPLY. The default translation table, QSYSTRNTBL, is used to translate the reply to uppercase characters.



Example 2: Message Requiring Any Reply

SNDUSRMSG MSG(¡¯Enter any response when ready to continue.¡¯)
TOMSGQ(WS01)

This command sends an inquiry message to a specific message queue. Any reply is valid. Because the purpose of this example is simply to wait, no CL variable is provided to receive the reply.



Example 3: Sending an Information Message

SNDUSRMSG MSGID(USR0150) TOUSR(FRED) MSGF(QGPL/USRMSGF)
MSGDTA(&ACCTNO) MSGTYPE(*INFO)

This command sends a predefined message as an information message to the message queue specified in the user profile of the specified user (FRED). The message data provided is included in the message.