Command reference / msg

SNDPGMMSG

Send Program Message

Sends a message to a named message queue or to a call message queue. A call message queue is either the *EXT external queue or a queue tied to a call stack entry, and each program or procedure call gets its own queue. A program can send to its own queue or to another call stack entry's queue. Exception messages interrupt the sender until action is taken, and processing may resume afterward; non-exception messages do not interrupt. The message can be immediate or predefined in a message file, with substitution data supplied in MSGDTA. It can go to *EXT, a call stack queue, nonprogram queues such as user profile queues, QSYSOPR, or the history log QHST.

Allowed environments: *BPGM, *IPGM, *BMOD, *IMOD, *BREXX, *IREXX. Positional parameters: 4.

Restrictions

Parameters

MSG Message text, or

Specifies the immediate message text to send, up to 3000 characters (512 when prompting in an interactive job). Enclose it in apostrophes if it contains blanks or special characters. Cannot be used with MSGID.

Type
*CHAR
Required
No
Length
3000
Case
Mixed case

MSGID Message identifier

Specifies the message ID of a message description whose predefined message is sent. Cannot be used with MSG. Requires MSGF.

Type
*NAME
Required
No
Length
7
Case
Uppercase

MSGF Message file

Specifies the message file containing the predefined message. Required when MSGID is specified.

Type
*QUAL
Required
No
Case
Uppercase
*LIBL
Searches the libraries in the thread's library list until the first match is found.
*CURLIB
Uses the job's current library, or QGPL if there is no current library entry.
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 one character string, or a CL variable containing one, of substitution values that fill the message's substitution variables in order. Cannot be used with MSG.

Type
*CHAR
Required
No
Default
*NONE
Length
3000
Case
Mixed case

Suggested / special values: *NONE

*NONE
No substitution values are used.

TOPGMQ Call stack entry message queue

Specifies the program message queue to receive the message: the *EXT external queue or the queue of a call stack entry.

Type
*ELEM
Required
No
Case
Uppercase

Suggested / special values: *EXT

*EXT
Sends to the job's external message queue. An inquiry to *EXT in an interactive job waits 24 hours before the default reply; in a batch job the default reply is sent immediately.
*PRV
Sends to the call stack entry immediately before the one identified.
*SAME
Sends to the call stack entry identified by the second element.
*
Identifies the OPM program or ILE procedure running this command.
*NONE
No module or program qualifier is given.
Elements in order

Relationship Relationship

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

Allowed values: *PRV, *SAME, *EXT

Call stack entry identifier Call stack entry identifier

Type
*NAME
Required
No
Default
*
Length
10
Case
Uppercase

Suggested / special values: *, *PGMBDY, *CTLBDY, *PGMNAME

TOMSGQ Send to non-program message queue

Specifies up to fifty nonprogram message queues that receive an informational message. An inquiry can go to one queue, or to two if one is *HSTLOG. Cannot be used with TOUSR.

Type
*QUAL
Required
No
Default
*TOPGMQ
List limit
50
Case
Uppercase

Suggested / special values: *TOPGMQ, *SYSOPR

*TOPGMQ
Sends only to the call message queue given in TOPGMQ.
*SYSOPR
Sends to QSYS/QSYSOPR. A copy also goes to QHST.
*HSTLOG
Sends to the system history log queue QSYS/QHST.
*LIBL
Searches the libraries in the thread's library list until the first match is found.
*CURLIB
Uses the job's current library, or QGPL if there is no current library entry.
Qualified parts (object, then library; write LIBRARY/OBJECT)

Message queue 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

Sends the message to the message queue in the named user profile. Cannot be used with TOMSGQ or TOPGMQ.

Type
*NAME
Required
No
Length
10
Case
Uppercase

Suggested / special values: *SYSOPR, *REQUESTER, *ALLACT

*SYSOPR
Sends to QSYS/QSYSOPR. A copy also goes to QHST.
*REQUESTER
Sends to the user profile queue for interactive jobs, or to QSYSOPR for batch jobs.
*ALLACT
Sends a copy to the user profile queue of each user with a running interactive job. Cannot be used with inquiry messages.

MSGTYPE Message type

Specifies the type assigned to the message when this program sends it. Inquiries go only to *EXT or to named queues; completion, diagnostic, escape, notify, and status messages go only to call message queues.

Type
*CHAR
Required
No
Default
*INFO
Length
7
Case
Uppercase

Allowed values: *INFO, *INQ, *RQS, *COMP, *DIAG, *NOTIFY, *ESCAPE, *STATUS

*INFO
Informational message.
*INQ
Inquiry message that the receiver can reply to.
*COMP
Completion message reporting successfully performed work; sent to a call message queue.
*DIAG
Diagnostic message describing errors found by this program; sent to a call message queue.
*NOTIFY
Notify message requiring corrective action before the sender continues; a reply comes back and the sender can resume.
*ESCAPE
Escape message for an irrecoverable error; the sending program does not resume.
*RQS
Request message passing request data from device files to another program or procedure. Must be sent with MSG.
*STATUS
Status message describing work performed. Monitors compare the first 28 characters of MSGDTA. Cannot be used with MSG.

RPYMSGQ Message queue to get reply

Specifies, for inquiry and notify messages only, the call or nonprogram message queue that receives the reply. Must be *PGMQ for notify messages and for inquiries sent to *EXT.

Type
*QUAL
Required
No
Default
*PGMQ
Case
Uppercase

Suggested / special values: *PGMQ

*PGMQ
The reply goes to the message queue of the call stack entry of the program or procedure running this command.
Qualified parts (object, then library; write LIBRARY/OBJECT)

Message queue 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

KEYVAR CL var for KEYVAR (4)

Names a 4-character CL variable that receives the message reference key the system assigns to the sent message. For inquiries it can be used to retrieve the reply, for example with RCVMSG MSGKEY.

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

CCSID Coded character set ID

Specifies the CCSID of the supplied message or message data. Valid values are 1 through 65535, and the command validates the value.

Type
*INT4
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 this command.
*HEX
The text is not converted; CCSID 65535 is used.

Examples

SNDPGMMSG MSGID(UIN0023) MSGF(INV) MSGDTA('50 100') TOPGMQ(*EXT)

Sends predefined message UIN0023 from file INV to the job's external message queue with two substitution values, 50 and 100.

IBM command documentation

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