Using the Send User Message (SNDUSRMSG) 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 command entry display 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 Save Object (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. If the SAVOBJ command completes successfully, the completion message is sent to the call message queue associated with the program that displays the command entry display.
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.