Send Message (SNDMSG)

The Send Message (SNDMSG) command is used by a display station user to send an immediate message from his display station to one or more message queues. (An immediate message is a message that is not predefined and is not stored in a message file.) The message can be sent to the system operator, to other display station users, to a user's message queue, all currently active users' message queues or to the system history log, QHST. The sender can require a reply from the message receiver. The primary users of this command are display station users and the system operator.

Restrictions:

  1. You must have object operational (*OBJOPR) and add (*ADD) authorities for the message queue.
  2. You must have use (*USE) authority for the specified message queues and *USE authority for the libraries in which they are located.
  3. The SNDMSG command only allows a message of up to 512 characters of first-level message text to be sent.
  4. This command can only send inquiry messages (specified by MSGTYPE(*INQ)) to one message queue or to two message queues if one of the queues is *HSTLOG.

Parameters

Keyword Description Choices Notes
MSG Message text Character value Required, Positional 1
TOUSR To user profile Name, *SYSOPR, *ALLACT, *REQUESTER Optional, Positional 3
TOMSGQ To message queue Single values: *SYSOPR
Other values (up to 50 repetitions): Qualified object name
Optional, Positional 2
Qualifier 1: To message queue Name, *HSTLOG
Qualifier 2: Library Name, *LIBL, *CURLIB
MSGTYPE Message type *INFO, *INQ Optional, Positional 4
RPYMSGQ Message queue to get reply Single values: *WRKSTN
Other values: Qualified object name
Optional
Qualifier 1: Message queue to get reply Name
Qualifier 2: Library Name, *LIBL, *CURLIB
CCSID Coded character set ID 1-65535, *HEX, *JOB Optional

Message text (MSG)

Specifies the immediate message that is being sent. The text must be enclosed in apostrophes if it contains blanks or other special characters. A maximum of 512 characters can be specified.

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 the coded character set identifier is supplied for the CCSID parameter. For more information about the message handler and its use of CCSIDs, see the i5/OS globalization topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

This is a required parameter.

To user profile (TOUSR)

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.

Either this parameter or the To message queue (TOMSGQ) parameter is required.

user-profile-name
Specify the user profile name of the user to whom the message is sent.
*SYSOPR
The message is sent to the system operator message queue, QSYS/QSYSOPR. Any message sent to QSYSOPR automatically has a copy of the message sent to QHST.
*REQUESTER
The message is sent to the user profile message queue for interactive jobs or to the system operator's message queue (QSYS/QSYSOPR) for batch jobs.
*ALLACT
A copy of the message is sent to the user profile message queue of each user profile with an interactive job currently running. *ALLACT cannot be specified with inquiry messages.

To message queue (TOMSGQ)

Specifies one to fifty message queues to which an informational message is sent. For an inquiry message, one message queue may be specified or two message queues may be specified if one of the queues is *HSTLOG. This parameter cannot be used if a value is specified for the To user profile (TOUSR) parameter.

Either this parameter or the To user profile (TOUSR) parameter is required.

Single values

*SYSOPR
The message is sent to the system operator message queue, QSYS/QSYSOPR. Any message sent to QSYSOPR automatically has a copy of the message sent to QHST.

Qualifier 1: To message queue

*HSTLOG
The message is sent to the system history log message queue, QSYS/QHST. If *HSTLOG is specified more than once, only one message will be sent to QSYS/QHST. If *HSTLOG is specified with QSYSOPR only one message is sent to QSYS/QHST.
message-queue-name
Specify the name of the message queue to which the message is to be sent.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is used to locate the message queue. If no current library entry exists in the library list, QGPL is used.
library-name
Specify the library where the message queue is located.

Message type (MSGTYPE)

Specifies the type of message to be sent. Only an informational or inquiry message can be specified.

*INFO
An informational message is to sent.
*INQ
An inquiry message is to be sent. The message queue receiving the message can reply to it. Inquiry messages are sent to only one message queue at a time or a second queue can be specified for TOMSGQ if the value is *HSTLOG.

Message queue to get reply (RPYMSGQ)

Specifies, only if an inquiry message is sent, the message queue to which a reply is sent.

Single values

*WRKSTN
The reply to the message is sent to the display station message queue associated with the sender's display station.

Note: This value cannot be specified for batch jobs.

Qualifier 1: Message queue to get reply

message-queue-name
Specify the name of the message queue to which a reply is sent. For example, a user message queue, a display station message queue, or the system operator message queue can be specified.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is used to locate the message queue. If no current library entry exists in the library list, QGPL is used.
library-name
Specify the library where the message queue is located.

Coded character set ID (CCSID)

Specifies the coded character set identifier (CCSID) that the supplied message text is in. For more information about the message handler and its use of CCSIDs, see the i5/OS globalization topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

*JOB
The message text is assumed to be in the CCSID of the job running this command.
*HEX
The message text is not converted. CCSID 65535 is used.
coded-character-set-identifier
Specify a valid CCSID in which you want your message text to be considered in. Valid values are between 1 and 65535. This command validates the CCSID.

Examples

Example 1: Sending Message to User Message Queue

SNDMSG   MSG('Do you want to update INV now?')  TOUSR(JONES)
         MSGTYPE(*INQ)  RPYMSGQ(SMITH)

This command sends a message to the user message queue JONES. When the message is answered, the reply will be sent to the message queue SMITH.

Example 2: Sending Message to System's History Log

SNDMSG   MSG('Errors on PAYROLL cost me 1 hour of run time.')
         TOMSGQ(QHST)

This command is used by the system operator to send an informational message to the system's history log, QHST, through the log's message queue, which has the same name.

Example 3: Sending Message to System Operator

SNDMSG   MSG('Please make 2 copies of file LABORSTAT.')
         TOMSGQ(QSYSOPR)

This command shows a typical use of the SNDMSG command by a display station user. The user is sending the message to the system operator.

Example 4: Sending Message that Requires a Reply

SNDMSG   MSG ('How long will the system be up today?')
         TOMSGQ(*SYSOPR)  MSGTYPE(*INQ)

This command sends an inquiry message to the system operator. The message requires a reply. The system operator displays the message by using the DSPMSG command and enters the reply on the display. The reply is then sent to the display station user's work station message queue. The display station user enters another DSPMSG command to display the reply.

Error messages

*ESCAPE Messages

CPF2428
Message queue parameter is not valid.
CPF2433
Function not allowed for system log message queue &1.
CPF2469
Error occurred when sending message&1.
CPF247E
CCSID &1 is not valid.
CPF2488
Reply message queue *WRKSTN not valid for batch job.
CPF9830
Cannot assign library &1.
CPF9838
User profile storage limit exceeded.