CL Programming

Messages

Inquiry and Informational Messages

Using the SNDUSRMSG command, you can send an inquiry message or an informational message to a display station user, the system operator, or a user-defined message queue. If you use the SNDUSRMSG command to send an inquiry message to the user, the procedure or program waits for a response from the user. The message can be either an immediate message or a predefined message. For an interactive job, the message is sent to the display station operator by default. For a batch job, the message is sent to the system operator by default. To send a message from a procedure or program using the SNDUSRMSG command, you can specify the following on the SNDUSRMSG command:

Completion and Diagnostic Messages

Using the SNDPGMMSG command, you can send diagnostic and completion messages. You can send these message types to any message queue from your CL procedure or program. Diagnostic messages tell the calling program or procedure about errors detected by the CL procedure or program. Completion messages tell the results of work done by the CL procedure or program.

Normally, an escape message is sent to the message queue of the calling program or procedure to tell the caller what the problem was or that diagnostic messages were also sent. For a completion message, an escape message is usually not sent because the requested function was performed.

For an example of sending a completion message, assume that the system operator uses the system operator menu to call a CL program SAVPAY to save certain objects. The CL program contains only the following procedure which saves the objects and then issues the following completion message:

PGM
SAVOBJ OBJ(PAY1 PAY2) LIB(PAYROLL) CLEAR(*YES)
SNDPGMMSG MSG('Payroll objects have been saved') MSGTYPE(*COMP)
ENDPGM

If the SAVOBJ command fails, the CL procedure function checks and the system operator has to display the detailed messages to locate the specific escape message explaining the reason for the failure as described later in this chapter. If the SAVOBJ command completes successfully, the completion message is sent to the call message queue associated with the program that displays the system operator menu.

One of the advantages of completion messages is their consistency with IBM-supplied commands. Many IBM commands send completion messages indicating successful completion. Seeing the type of message sent to the job log can assist in problem analysis.

Status Messages

You can send status messages from your CL procedure or program, using the SNDPGMMSG command, to a call message queue or to the external message queue (*EXT) for the job. When a status message is sent to a call message queue, the receiving program or procedure can monitor for the arrival of the status message and can handle the condition it describes. If the receiving program or procedure does not monitor for the message, control returns to the sender to resume processing. See Monitoring for Messages in a CL Program or Procedure.

Escape and Notify Messages

You can send escape messages from your CL procedure or program to the call message queue of the calling program or procedure with the SNDPGMMSG command. An escape message tells the caller that the procedure or program ended abnormally and why. The caller can monitor for the arrival of the escape message and handle the condition it describes. When the caller handles the condition, control does not return to the sender of an escape message.

If the caller is another procedure within the same program, the program itself does not end. The procedure to which the escape message was sent is allowed to continue. If the escape message was sent to the caller of the program itself, then all active procedures within the program are ended immediately. As a result, the program cannot continue to run. If the caller does not monitor for an escape message, default system action is taken.

You can send notify messages from a CL procedure or program to the message queue of the calling program or procedure or to the external message queue. A notify message tells the caller about a condition under which processing can continue. The calling program or procedure can monitor for the arrival of the notify message and handle the condition it describes. If the caller is an Integrated Language Environment procedure, it can perform the following functions:

If the caller is an OPM program and is not monitoring for the message, the sender receives a default reply. If the caller is an ILE procedure, then the message percolates to the control boundary. When finding no monitor, the system returns a default reply to the sender. The sender then resumes processing. See Monitoring for Messages in a CL Program or Procedure.

Immediate messages are not allowed as escape and notify messages. The system has defined the message CPF9898, which can be used for immediate escape and notify messages in application programs. For example:

SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Error condition') +
          MSGTYPE(*ESCAPE)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]