Where allowed to run: Compiled CL program or interpreted REXX (*BPGM *IPGM *BREXX *IREXX) Threadsafe: No |
Parameters Examples Error messages |
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:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
MSG | Message text, or | Character value | Optional, Positional 1 |
MSGID | Message identifier | Name | Optional |
MSGF | Message file | Qualified object name | Optional |
Qualifier 1: Message file | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
MSGDTA | Message data field values | Character value | Optional |
VALUES | Valid reply values | Values (up to 20 repetitions): Character value, *NONE | Optional |
DFT | Default reply value | Character value, *MSGDFT | Optional |
MSGTYPE | Message type | *INQ, *INFO | Optional |
TOMSGQ | To message queue | Single values: *, *EXT, *SYSOPR Other values: Qualified object name |
Optional |
Qualifier 1: To message queue | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
TOUSR | To user profile | Name, *SYSOPR, *REQUESTER | Optional |
MSGRPY | CL var for message reply | Character value | Optional |
TRNTBL | Translate table | Single values: *NONE Other values: Qualified object name |
Optional |
Qualifier 1: Translate table | Name, QSYSTRNTBL | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
CCSID | Coded character set ID | 1-65535, *HEX, *JOB | Optional |
Top |
Specifies the message text of an immediate message that is sent by the program. A maximum of 512 characters can be specified. The text string must be enclosed in apostrophes if special characters (including blanks) are used. If this parameter is specified, values cannot be specified for the Message identifier (MSGID) parameter, Message file (MSGF) parameter, or Message data field values (MSGDTA) parameter.
Coded Character Set Identifier (CCSID) Considerations
The text supplied for the MSG parameter is assumed to be in the CCSID of the job running this command unless a coded character set identifier is supplied in the CCSID parameter. For more information about the message handler and its use of CCSIDs, see the Globalization topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
Specifies the message identifier of a predefined message sent by the program to a message queue. If a value is specified for this parameter, a value must also be specified for the Message file (MSGF) parameter, and a value cannot be specified for the Message text, or (MSG) parameter.
Top |
Specifies the message file that contains the predefined message to be sent. This parameter is valid only if a value is specified for the Message identifier (MSGID) parameter.
Qualifier 1: Message file
Qualifier 2: Library
Top |
Specifies the character string or the CL variable that contains a character string used as the message data in the predefined message. A character string that is specified contains one or more substitution values that are used in place of the substitution variables that were defined in the message's text when the message was defined.
Coded Character Set Identifier (CCSID) Considerations
The text supplied for the MSGDTA parameter that corresponds to the *CCHAR type field is assumed to be in the CCSID of the job running this command unless a coded character set identifier is supplied in the CCSID parameter. All other text supplied for the MSGDTA parameter is assumed to be 65535 and is not converted. For more information about the message handler and its use of CCSIDs, see the Globalization topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter. For more information about the *CCHAR type field, see the Add Message Description (ADDMSGD) command.
Top |
Specifies a list of valid replies to an inquiry message sent by this command. No more than 20 replies can be specified in the list. If the reply to the inquiry message does not match one of the specified values, an error message is sent to the reply's sender and the inquiry message is sent again.
Top |
Specifies the value used as the reply to an inquiry message (sent by this command) if the inquiry message is sent to a message queue that is in default delivery mode, or for any other reason the default reply is sent.
Top |
Specifies the type of message to be sent.
Top |
Specifies the name of the message queue to which the message is to be sent. This parameter cannot be used if a value is specified for the To user profile (TOUSR) parameter.
Single values
Qualifier 1: To message queue
Qualifier 2: Library
Top |
Specifies that the message is to be sent to the message queue specified in the user profile for the user named on this parameter. This parameter cannot be used if a value is specified for the To message queue (TOMSGQ) parameter.
Top |
Specifies the CL character variable (of up to 132 characters) that contains the reply received in response to an inquiry message. This parameter is valid only if *INQ is specified for the Message type (MSGTYPE) parameter.
Top |
Specifies the name of the translation table that is used if the reply value is being translated.
Qualifier 1: Translate table
The IBM-supplied translation table QSYSTRNTBL table translates, for the English language only, all lowercase characters in the range of X'81' to X'A9' to uppercase characters. All other characters are not translated.
To use a different translation table, use the Create Table (CRTTBL) command and specify that particular table for this parameter.
Qualifier 2: Library
Top |
Specifies the coded character set identifier (CCSID) that the message text supplied for the MSG (message) or MSGDTA (message data) parameters is in. If a message identifier is specified, the text supplied by the MSGDTA (message data) parameter that corresponds to the *CCHAR type field is assumed to be in the CCSID supplied by this parameter. The data supplied that does not correspond to the *CCHAR type field is assumed to be 65535 and is not converted. For more information about the *CCHAR type field see the Add Message Description (ADDMSGD) command.
If no message identifier is specified, the text supplied by the MSG (message) parameter is assumed to be in the CCSID supplied by this parameter. For more information about the message handler and its use of CCSIDs, see the Globalization topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
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.
Top |
*ESCAPE Messages
Top |