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

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.

Type
*CHAR
Required
No
Length
512
Case
Mixed case

MSGID Message identifier

Specifies the ID of a predefined message to send. Requires MSGF, and cannot be combined with MSG.

Type
*NAME
Required
No
Length
7
Case
Uppercase

MSGF Message file

Specifies the message file containing the predefined message. Valid only when MSGID is specified.

Type
*QUAL
Required
No
Case
Uppercase
*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

Type
*NAME
Required
No
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

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.

Type
*CHAR
Required
No
Length
512
Case
Mixed case
*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).

Type
*CHAR
Required
No
Default
*NONE
Length
32
List limit
20
Case
Mixed case

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.

Type
*CHAR
Required
No
Default
*MSGDFT
Length
132
Case
Mixed case

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.

Type
*CHAR
Required
No
Default
*INQ
Length
5
Case
Uppercase

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.

Type
*QUAL
Required
No
Default
*
Case
Uppercase

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

Type
*NAME
Required
No
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

Suggested / special values: *LIBL, *CURLIB

TOUSR To user profile

Specifies the user whose profile message queue receives the message. Cannot be used with TOMSGQ.

Type
*NAME
Required
No
Length
10
Case
Uppercase

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.

Type
*CHAR
Required
No
Length
132
Case
Uppercase
Returns
CL variable

TRNTBL Translate table

Names the translation table used to translate the reply value. The IBM-supplied QSYSTRNTBL translates lowercase to uppercase, for English only.

Type
*QUAL
Required
No
Default
QSYSTRNTBL
Case
Uppercase

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

Type
*NAME
Required
No
Default
QSYSTRNTBL
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

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.

Type
*UINT2
Required
No
Default
*JOB
Range
1 to 65535
Case
Uppercase

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.

IBM command documentation

Generated from os/cl/catalog/SNDUSRMSG.json and os/cl/help/SNDUSRMSG.json.