An impromptu message is not predefined and is not stored in a message file. An impromptu message can be sent from one user to another; these messages may have no preset reply value. The message can be informational or for inquiry. We can send an impromptu message using the Send Message command, SNDMSG. The SNDMSG command only works with messages whose text is included within the MSG parameter of the command.
To send a message to a user, we use the TOUSR parameter. We can enter a specific user profile name or a special value; the special values that are allowed for this parameter are *SYSOPR, *ALLACT, and *REQUESTER. The *SYSOPR special value indicates the system operator’s message queue. The *ALLACT special value indicates all currently signed-on user profiles’ message queues. The *REQUESTER special value indicates the user profile currently running this interactive job.
The SNDMSG command allows us to send a message to the system operator without necessarily knowing the name of the user profile or message queue. All we need to do is specify TOUSR(*SYSOPR). We can also specify TOUSR(*ALLCT) if we want to broadcast a message to all users currently signed on. For example, we could issue the command SNDMSG MSG(‘Pizza in the break room!’) TOUSR(*ALLACT) to alert everyone that there is pizza in the break room. Finally, we can even send a message to ourselves by specifying TOUSR(*REQUESTER).
Note that we can enter the command DSPMSG to view messages sent to us.
To broadcast a message to all active user profiles, we would issue the command SNDMSG MSG(‘All active users will receive this message.’) TOUSR(*ALLACT). To send a message to the system operator, we issue the command SNDMSG MSG(‘This goes to the system operator’s message queue.’) TOUSR(*SYSOPR). Finally, to send a message to ourselves, for example as a reminder of things to do the next day, we can enter the command SNDMSG MSG(‘Bring donuts tomorrow.’) TOUSR(*REQUESTER).
As an alternative to sending the message to a user, we can send the message to a message queue using the TOMSGQ parameter. The disadvantage to using the TOMSGQ parameter is that we must know the name of the message queue assigned to the user; although, by default the message queue and the user name are the same. The advantage to using the TOMSGQ parameter is that we can send the same message to multiple specific users. The TOMSGQ parameter can accept a list of up to 50 values. As an example, we could issue the command SNDMSG MSG(‘The meeting time has been changed to Friday.’) TOMSGQ(ADALOV CBAB) to send a message to the ADALOV and CBAB users.
Be aware that the TOMSGQ and TOUSR parameters are mutually exclusive.
We can use the SNDMSG command to send an inquiry message. An inquiry message is a type of message we can send when we want the recipient to acknowledge and respond to the message. To send an inquiry message, we use the MSGTYPE parameter with the *INQ special value. The MSGTYPE parameter defaults to *INFO, which means the message is just informational. For example, to send an inquiry message to the security officer, we would issue the command SNDMSG MSG(‘Why is a raven like a writing desk?’) TOUSR(QSECOFR) TYPE(*INQ). Note that the MSGTYPE(*INQ) is invalid if TOUSR(*ALLACT) is specified or if TOMSGQ contains multiple values.
If the MSGTYPE(*INQ) is specified, we can identify a message queue to receive the reply with the RPYMSGQ parameter. The default value of the RPYMSGQ parameter is *WRKSTN. If *WRKSTN is used, the reply is sent back to the workstation message queue associated with the interactive job that sent the message, unless the job is a batch job, in which case the reply is sent to the QSYSOPR message queue.
As messages are not displayed the moment they are received, there can be a delay of indeterminate length between the time we send a message and the time the recipient actually reads it. If the message is urgent, we can send a break message. To send a break message, we use the Send Break Message command, SNDBRKMSG. Unless the message queue has been altered with a program to handle break messages, the message interrupts the interactive job of the recipient.
The Send Break Message command, SNDBRKMSG, delivers messages only to a workstation message queue. The SNDBRKMSG command has two required parameters, MSG and TOMSGQ. To send a break message to all active workstations, we issue the command SNDBRKMSG MSG(‘Photons be free!’) TOMSGQ(*ALLWS). The *ALLWS special value used here indicates all work station message queues.
We can prompt for the SNDBRKMSG command by entering the command on the prompt and then pressing F4. We will then have to type the message text and identify who should receive the message.
Please note that the Send Program Message, SNDPGMMSG, and the Send User Message, SNDUSRMSG, commands can be used only from within a CL program.