Command reference / CL

MONMSG

Monitor Message

Monitors escape, notify, and status messages sent to the program message queue of the program containing the command; completion, diagnostic, and other message types cannot be monitored. A command-level MONMSG applies only to the immediately preceding command, while a program-level MONMSG placed at the start of the program applies to messages from all commands in the program (up to 100); a command-level MONMSG overrides a program-level one.

Allowed environments: *BPGM, *IPGM. Use within a CL program. Positional parameters: 3.

Restrictions

Parameters

MSGID Message identifier

Specifies the message identifiers of one or more escape, notify, or status messages to be monitored by this command. Up to 50 specific or generic identifiers can be specified.

Type
*NAME
Required
Yes
Length
10
List limit
50
Case
Uppercase

CMPDTA Comparison data

Specifies comparison data used to decide whether a monitored message is acted on by this command. It is compared with the first part (up to 28 characters) of the message's substitution values.

Type
*CHAR
Required
No
Default
*NONE
Length
50
Case
Uppercase

Suggested / special values: *NONE

*NONE
No comparison data is specified. If the message is from a monitored command and has the specified identifier, the EXEC action is taken.

EXEC Command to execute

Specifies the CL command to be processed when a monitored message sent to the program's message queue meets the conditions specified in this command. If no command is specified, the message is ignored and control passes to the next command.

Type
*CMDSTR
Required
No
Case
Uppercase

Examples

MONMSG MSGID(CPF0001 CPF1999) EXEC(GOTO EXIT2)

Placed at the start of a CL procedure, it monitors messages that any later command may send; on either message, control branches to the label EXIT2.

MONMSG MSGID(MCH1211) EXEC(CHGVAR VAR(&A) VALUE(1))

Follows a CHGVAR command and monitors only that command; when the division by zero sends MCH1211, the second CHGVAR sets &A to 1.

IBM command documentation

Generated from os/cl/catalog/MONMSG.json and os/cl/help/MONMSG.json.