Send messages from a CL program

Various message types are described in this topic. Use the Send Program Message (SNDPGMMSG) command or the Send User Message (SNDUSRMSG) command to send a message from a CL procedure or program.

Using the Send Program Message (SNDPGMMSG) command, you can send the following types of messages:

You can send messages from a CL procedure or program to the following types of queues:

To send a message from a procedure or program, you can specify the following on the SNDPGMMSG command:

Table 1. Valid Message Types for Message Queue Types
Message Type Message Queue Type
External Call QSYSOPR WorkStation User
Informational V V V V V
Inquiry V   V V V
Completion V V V V V
Diagnostic V V V V V
Request V V      
Escape   V      
Status V V      
Notify V V      

To send the message created in Example: Describe a message, you would use the following command:

SNDPGMMSG   MSGID(USR4310) MSGF(QGPL/USRMSG) +
            MSGDTA(&CUSNO) TOPGMQ(*EXT) +
            MSGTYPE(*INFO)

The substitution variable for the message is the customer number. Because the customer number varies, you cannot specify the exact customer number in the message. Instead, declare a CL variable in the CL procedure or program for the customer number (&CUSNO). Then specify this variable as the message data field. When the message is sent, the current value of the variable is passed in the message:

Customer number 35500 not found

In addition, you do not always know which display station is using the procedure or program, so you cannot specify the exact display station message queue that the message is to be sent to (TOMSGQ parameter); therefore, you specify the external message queue *EXT on the TOPGMQ parameter.

Related concepts
Identify the base entry by name
Related tasks
Send messages to a system user
Example: Describe a message
Receive request messages
Related information
Types of message queues