You can send both escape and notify messages from your CL procedure or program to message queues.
You can send escape messages from your CL procedure or program to the call message queue of the calling program or procedure with the Send Program Message (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.
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)