CLRMSGQ (Clear Message Queue)

CLRMSGQ Command syntax diagram

 

Purpose

The Clear Message Queue (CLRMSGQ) command clears (removes) all messages from a specified message queue. Once cleared, the data cannot be shown or printed. If the specified message queue is not allocated to a job, it is implicitly allocated by this command for the duration of the command. If the specified message queue is *WRKSTN or a work station message queue, it is not allocated and the message queue is cleared even if the work station device description is allocated to another job.

 

Required Parameters

MSGQ
Specifies the qualified name of the message queue that is cleared. If a specific message queue name is specified (instead of a generic name), only the first message queue found with that name is cleared.

*WRKSTN: The work station message queue is cleared. This is not allowed in batch mode.

The name of the message queue can be qualified by one of the following library values:

*LIBL: All libraries in the job's library list are searched until the first match is found.

*CURLIB: The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.

library-name: Specify the name of the library to be searched.

message-queue-name: Specify the name of the message queue that is cleared.

 

Optional Parameters

CLEAR
Specifies which messages are cleared from the message queue.

*ALL: All messages are cleared from the message queue. If there are unanswered messages on the queue, the default reply is returned to the sender before the message is cleared.

*KEEPUNANS: Unanswered inquiry messages remain on the specified message queue. Other messages are removed.

Examples for CLRMSGQ

Example 1: Clearing All Messages

CLRMSGQ   MSGQ(*CURLIB/MQFIN)

This command clears all messages from a message queue named MQFIN, which is located in the current library for the job.

Example 2: Keeping Unanswered Messages

CLRMSGQ   MSGQ(*CURLIB/MQFIN)  CLEAR(*KEEPUNANS)

This command clears all messages except unanswered inquiry messages from a message queue called MQFIN, which is located in the current library for the job.

Error messages for CLRMSGQ

*ESCAPE Messages

CPF2357
Message queue &1 in &2 not cleared.