SNDMSG (Send Message)

SNDMSG Command syntax diagram

 

Purpose

The Send Message (SNDMSG) command is used by display station users to send immediate messages from their display stations 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, to all currently active user's 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 operators and the system operator.

 

Restrictions

  1. The user must have object operational and add authorities to the message queue.
  2. The user of this command must have *USE authority for the specified message queues and for the libraries in which they are stored.
  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.

 

Required Parameters

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

Coded Character Set Identifier (CCSID) Considerations

The text supplied on 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 Information Center.

TOUSR
Specifies that the message is sent to the message queue specified in the user profile for the user named on this parameter. This parameter cannot be used if TOMSGQ is specified.

*SYSOPR: The message is sent to the system operator's 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's 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. This value cannot be specified if the value *INQ is specified for the MSGTYPE parameter.

user-profile-name: Specify the user profile name of the user to whom the message is sent.

TOMSGQ
Specifies the qualified names of up to 50 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 TOUSR is specified.

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

The name of the message queue can be qualified by one of the following library values:

*LIBL: All libraries in the job's library list are searched until the first match is found.

*CURLIB: The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.

library-name: Specify the name of the library to be searched.

message-queue-name: Specify the name of the message queue to which messages are sent.

*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.

 

Optional Parameters

MSGTYPE
Specifies the type of message being sent. Only informational and inquiry message types can be specified.

*INFO: An informational message is sent.

*INQ: An inquiry message is 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.

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

*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.

The name of the message queue can be qualified by one of the following library values:

*LIBL: All libraries in the job's library list are searched until the first match is found.

*CURLIB: The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.

library-name: Specify the name of the library to be searched.

message-queue-name: Specify the name of the message queue to which the reply is sent.

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 Globalization topic in the Information Center.

*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 for SNDMSG

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('Input 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 printer
  file LABORSTAT.')  TOMSGQ(QSYSOPR)

This example shows a typical use of the SNDMSG command by a display station user. The user is sending the message 'Please make 2 copies of printer file LABORSTAT.' to the system operator.

Example 4: Sending Message that Requires a Reply

SNDMSG   MSG ('How long will the display stations be
  online today?')  TOMSGQ(*SYSOPR)  MSGTYPE(*INQ)

This inquiry message from a display station user 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 for SNDMSG

*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.