Messages are held on a message queue until they are removed
You can remove them using the Remove Message (RMVMSG) command, Clear Message Queue (CLRMSGQ) command, the RMV parameter on the Retrieve Message (RTVMSG) and Send Reply (SNDRPY) commands, the remove function keys of the Display Messages display, or the clear message queue option on the Work with Message Queue display. You can remove:
To remove a single message using the Remove Message (RMVMSG) command or a single old message using the Retrieve Message (RTVMSG) command, you specify the message reference key of the message to be removed.
To remove all messages for all inactive programs and procedures from a user's job message queue, specify *ALLINACT for the PGMQ parameter and *ALL for the CLEAR parameter on the Remove Message (RMVMSG) command. If you want to print your job log before you remove all the inactive messages, use the Display Job Log (DSPJOBLOG) command and specify *PRINT for the OUTPUT parameter.
When working with a call message queue of an ILE procedure, it is possible that an exception message for unhandled exceptions is on the queue at the time the Remove Message (RMVMSG) command is run. The RMVEXCP keyword of this command can be used to control actions for messages of this type. If *YES is specified for this keyword, the RMVMSG command causes the exception to be handled and the message to be removed. If *NO is specified, the message is not removed. As a result, the exception is not handled.
The following Remove Message (RMVMSG) command removes a message from the user message queue JONES. The message reference key is in the CL variable &MRKEY.
DCL &MRKEY TYPE(*CHAR) LEN(4) RCVMSG MSGQ(JONES) RMV(*NO) KEYVAR(&MRKEY) RMVMSG MSGQ(JONES) MSGKEY(&MRKEY)
The following Remove Message (RMVMSG) command removes all messages from the call message queue for the procedure containing the command.
RMVMSG CLEAR(*ALL)