Monitor Message command
The Monitor Message (MONMSG) command is used to monitor for escape, notify, or status messages that are sent to the call stack of the CL program or procedure in which the MONMSG command is used.
Using the MONMSG command, you can direct a program or procedure to take predetermined action if specific errors occur during the processing of the immediately preceding command. The MONMSG command has the following parameters:
MONMSG MSGID(message-identifier) CMPDTA(comparison-data) +
EXEC(CL-command)
Each message that is sent for a specific error has a unique identifier. You can enter as many as 50 message identifiers on the MSGID parameter.
The MONMSG command has the following parameters:
MONMSG MSGID(message-identifier) CMPDTA(comparison-data) + EXEC(CL-command)
The MONMSG message id CPF0000 monitors for messages CPF0001 and CPF9999;
If you code the MONMSG command at the beginning of your CL program or procedure, the messages you specify are monitored throughout the program, regardless of which command produces these messages.
MONMSG MSGID(CPF0000)
0038.00 CPYF FROMFILE(&LIBI/&FILI) TOFILE(*LIBL/XXXXXXX) +
0039.00 FROMMBR(&TEMI) TOMBR(XXXXXXX) +
0040.00 MBROPT(*REPLACE) CRTFILE(*NO) FMTOPT(*NOCHK)
0041.00 MONMSG MSGID(CPF0000)
0042.00
0051.00 CHKOBJ OBJ(&FILLIB/&FILENAME) OBJTYPE(*FILE)
0052.00 MONMSG MSGID(CPF9800 CPF9801 CPF9815) EXEC(DO)
0053.00 CRTPF FILE(&FILLIB/&FILENAME) RCDLEN(&RECLENGTH) +
0054.00 MAXMBRS(*NOMAX) SIZE(*NOMAX)
0055.00 ENDDO
0052.00 /* Check if member already present in File, If Present then clear it*/
0053.00
0054.00 CHKOBJ OBJ(&LIB/&FILENAME) OBJTYPE(*FILE) +
0055.00 MBR(&MBRNME)
0056.00 MONMSG MSGID(CPF9815) EXEC(DO)
0057.00 ADDPFM FILE(&LIB/&FILENAME) MBR(&MBRNME)
0058.00 MONMSG MSGID(CPF3204 CPF7306) EXEC(DO)
0059.00 SNDPGMMSG MSG('File member not created')
0060.00 GOTO CMDLBL(END)
0061.00 ENDDO
0062.00 ENDDO
0107.00 ADDLIBLE LIB(TAATOOL) POSITION(*AFTER QTEMP)
0108.00 MONMSG MSGID(CPF2103)
0223.00 CRTDUPOBJ OBJ(&FILE1) FROMLIB(*LIBL) OBJTYPE(*FILE) +
0224.00 TOLIB(&LIB1)
0225.00 ADDPFM FILE(&LIB1/&FILE1) MBR(&MEMBER1)
0226.00 MONMSG MSGID(CPF0000)
0227.00 ENDDO