A message is a form of communication between any two entities. When you talk to another person, you and the other person are exchanging messages. You are taking turns transmitting one message at a time in the form of speech. In computer terms, a message is also a form of communication between the computer and a user, between two users, or between two computer programs. While all three forms of messages have their specific uses (and are equally important), this chapter deals exclusively with messages exchanged between two users. Many of the techniques described here can also be applied to other kinds of messages.
You might want to send a message to another user for many reasons. For example, you may need to inform the user that his report has finished printing and is ready for pick-up in the computer room. Or, you may need to tell all users that the system will be shut down at 4:30 P.M. for a release upgrade.
Whatever the case, sending a user message helps you convey these ideas or announcements to your users. To send a message, you run the Send Message (SNDMSG) command.
The SNDMSG command has five parameters, but for most practical purposes you need concern yourself only with the first three. Using these three parameters, you indicate who should receive the message and what the message should say.
For example, suppose you want to send a message to user LARRY, to tell him that the inventory master parts list he requested has printed. To do this, enter:
SNDMSG MSG('Your inventory master parts list is printed.') + TOUSR(LARRY)
Note that you have used two parameters: MSG, to spell out the text of the message, and TOUSR, which indicates what user receives the message. Alternatively, you could have used the TOMSGQ parameter (instead of TOUSR). The disadvantage is that you must know the name of the message queue that has been assigned to user LARRY. By using the TOUSR parameter, however, the system performs that search for you.
The TOUSR parameter has one limitation that is not shared by the TOMSGQ parameter: It can accept only one name. Using the TOMSGQ parameter, you can send the same message to several users. Or, more accurately, to as many as 50 message queues:
SNDMSG MSG('Time to start our meeting in the Computer + Room.') TOMSGQ(JODY JIM JENNIFER JUSTIN)
In this case, the same message ("Time to start our meeting in the computer room.") would be sent to message queues JODY, JIM, JENNIFER, and JUSTIN. The distinction between user and message queue is important. When the security administrator creates a user profile, he has to assign a message queue for the new user. The name of the message queue defaults to the user profile name. A user named JUSTIN would have a message queue of the same name. In this case, it makes no difference whether you use the TOUSR or the TOMSGQ parameter, because the names are identical. Keep in mind, however, that this similarity is not necessarily so.
The SNDMSG command allows you to send a message to the system operator. All you need do is specify TOUSR(*SYSOPR) or TOMSGQ(*SYSOPR). Again, you can see the similarity between TOUSR and TOMSGQ. The system operator's profile name is QSYSOPR and so is the name of its message queue.
You can also specify TOUSR(*ALLACT) if you want to broadcast the message to all users currently signed on. Finally, you can specify TOUSR(*REQUESTER) if you want to send a message to yourself. For example, you might want to send yourself a reminder of things to do the next day, just before you sign off and go home in the evening.
Another use of the SNDMSG command hasn't been discussed yet: sending an inquiry message. An inquiry message is a type of message you send when you want the recipient to acknowledge it and give you an answer. The system uses inquiry messages liberally. You can take advantage of them, too.
For example, you can send the following inquiry message to user LARRY:
SNDMSG MSG('I need to shut down the system. How much + longer are you going to use it?') + TOUSR(LARRY) + MSGTYPE(*INQ)
When LARRY sees this message, the system provides an input field that goes all the way across the screen, right below the message text. LARRY can then type the answer and press Enter; when he does that, you get the answer at your terminal.
You can even specify where to receive the reply, with the help of the RPYMSGQ parameter. This parameter always defaults to *WRKSTN, which means that your display station's message queue receives the reply. However, nothing prevents you from entering a different value in the RPYMSGQ parameter if, for example, you want your supervisor GEORGE to receive the reply. In this case, you would indicate RPYMSGQ(GEORGE).
Sending inquiry messages has two restrictions, however. You cannot specify TOUSR(*ALLACT) or indicate more than one name in the TOMSGQ parameter, because you would not want the answer to come from all recipients at once, or from any one of them.