- The image catalog entry may already exist (same CD inserted twice)
- The image file was not deleted on the IFS
- There is no CD inserted
I want to handle these three cases separately, but I did not find out how to monitor the information messages produced. The only message I can monitor is the CPFBC28, but I need OPT1660 (no CD), CPDBC19 (IMGF exists) and CPDBC29 (IMGCLGE exists).
MONMSG MSGID(CPFBC28) EXEC(GOTO CMDLBL(NOCD1)) /*
temporary to make it work
/* MONMSG MSGID(OPT1660) EXEC(GOTO CMDLBL(NOCD1)) */
/* These are the three
/* MONMSG MSGID(CPDBC19) EXEC(GOTO CMDLBL(IMGFEXT1)) */
/* messages I want to
/* MONMSG MSGID(CPDBC29) EXEC(GOTO CMDLBL(IMGCEXT1)) */
/* check for
MONMSG MSGID(CPFBC28) EXEC(DO)
RCVMSG MSGTYPE(*DIAG) MSGID(&MGID)
IF COND(&MGID *EQ 'CPDBC19') THEN(GOTO
IF COND(&MGID *EQ 'CPDBC29') THEN(GOTO
The CPD and OPT messages are diagnostic messages, not escape messages, so they cannot be monitored. When an error occurs on an IBM command, the diagnostic messages are sent first, then an escape message, which you can monitor.
So, you see the escape message, and then you use the RCVMSG command to get the last diagnostic message sent to your program. The variable &MGID is *CHAR 7, and will contain the message ID of the diagnostic message, or will be blank if there was no diagnostic message to receive.
Inside the DO group there is an unconditional GOTO to catch an error that did not return the diagnostic message you expected. There is no need to check for the OPT1660 message because its destination is the same as the unconditional GOTO.
This was first published in July 2008