Command reference / msg
SNDUSRMSG
Send User Message
Lets a CL program send a message to a message queue and optionally receive a reply. The message can be impromptu or predefined, and can go to a display station user in an interactive job or to a specific message queue. For inquiry messages, a CL variable can receive the reply and the program waits for it. The command also validates and converts replies to inquiry messages to uppercase.
Allowed environments: *BPGM, *IPGM, *BREXX, *IREXX.
Positional parameters: 1.
Restrictions
- Valid only in CL programs.
- Up to 512 characters of first-level message text can be sent. To an external queue (*EXT) in an interactive job only 76 characters show on the Display Program Messages display; DSPMSG shows all 512 for user, workstation, or system operator queues.
Parameters
MSG
Message text, or
Specifies the text of an immediate message to send, up to 512 characters, enclosed in apostrophes if it has special characters or blanks. Cannot be combined with MSGID, MSGF, or MSGDTA.
MSGID
Message identifier
Specifies the ID of a predefined message to send. Requires MSGF, and cannot be combined with MSG.
MSGF
Message file
Specifies the message file containing the predefined message. Valid only when MSGID is specified.
*LIBL- All libraries in the thread's library list are searched until the first match is found.
*CURLIB- The job's current library is used; if none is set, QGPL is used.
Qualified parts (object, then library; write LIBRARY/OBJECT)
Message file
Message file
Library
Library
Suggested / special values:
*LIBL, *CURLIB
MSGDTA
Message data field values
Specifies a character string or CL variable holding substitution values for the predefined message's variables. Valid only for predefined messages.
*NONE- No message data is specified for the predefined message.
VALUES
Valid reply values
Lists up to 20 valid replies to the inquiry; any other reply is rejected, an error goes to the replier, and the inquiry is sent again. Requires MSGRPY and MSGTYPE(*INQ).
Suggested / special values:
*NONE
*NONE- No replies are restricted; any reply is valid.
DFT
Default reply value
Specifies the reply used when the inquiry goes to a queue in default delivery mode or the default reply is otherwise sent. Requires MSGRPY.
Suggested / special values:
*MSGDFT
*MSGDFT- The default in the message ID's message description is used; if no message ID is given, *N is used.
MSGTYPE
Message type
Specifies whether the message is an inquiry or an informational message.
Allowed values:
*INQ, *INFO
*INQ- An inquiry is sent and the receiving message queue must reply to it.
*INFO- An informational message is sent.
TOMSGQ
To message queue
Specifies the message queue that receives the message. Cannot be used with TOUSR.
Suggested / special values:
*, *EXT, *SYSOPR
*- In an interactive job the message goes to the external queue (*EXT); in a batch job it goes to the system operator queue QSYSOPR in library QSYS.
*EXT- The message goes to the job's external message queue; in batch, an inquiry always receives its default reply.
*SYSOPR- The message goes to the system operator queue QSYSOPR in library QSYS.
*LIBL- All libraries in the thread's library list are searched until the first match is found.
*CURLIB- The job's current library is used; if none is set, QGPL is used.
Qualified parts (object, then library; write LIBRARY/OBJECT)
To message queue
To message queue
Library
Library
Suggested / special values:
*LIBL, *CURLIB
TOUSR
To user profile
Specifies the user whose profile message queue receives the message. Cannot be used with TOMSGQ.
Suggested / special values:
*SYSOPR, *REQUESTER
*SYSOPR- The message goes to the system operator user profile queue, QSYS/QSYSOPR.
*REQUESTER- Interactive jobs send to the user profile message queue; batch jobs send to QSYS/QSYSOPR.
MSGRPY
CL var for message reply
Names the CL character variable (up to 132 characters) that receives the reply to an inquiry. The command waits for a reply to an inquiry even if this is omitted. Valid only for *INQ.
TRNTBL
Translate table
Names the translation table used to translate the reply value. The IBM-supplied QSYSTRNTBL translates lowercase to uppercase, for English only.
Suggested / special values:
*NONE
*NONE- The reply is not translated.
*LIBL- All libraries in the thread's library list are searched until the first match is found.
*CURLIB- The job's current library is used; if none is set, QGPL is used.
Qualified parts (object, then library; write LIBRARY/OBJECT)
Translate table
Translate table
Library
Library
Suggested / special values:
*LIBL, *CURLIB
CCSID
Coded character set ID
Specifies the CCSID of the MSG or MSGDTA text. For predefined messages, the *CCHAR-type MSGDTA field uses this CCSID and other data is treated as CCSID 65535 without conversion.
Suggested / special values:
*HEX, *JOB
*JOB- The text is assumed to be in the CCSID of the job running the command.
*HEX- The text is not converted and CCSID 65535 is used.
Examples
SNDUSRMSG MSG('Data verified. Update master files (Y,N)?') TOMSGQ(*) VALUES(Y N) DFT(N) MSGRPY(&REPLY)
Sends an inquiry to the display station operator in an interactive job or the system operator in a batch job. Only Y or N is accepted, and the reply is placed in &REPLY.
Generated from os/cl/catalog/SNDUSRMSG.json and os/cl/help/SNDUSRMSG.json.