I've written a program to help the user load and install his PTFs. I am loading the CDs into image files, and there...
comes my problem: When loading an image, three different problems occur, which I want to handle separately.
- 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).
The following code will work for this problem: Original code:
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.
Dig Deeper on iSeries programming commands
Related Q&A from John Blenkinsop
Learn how to 'append data to the file' with the FTP DIR command, and eliminate the hassle of having to end the FTP session and restart to view ... Continue Reading
RPGIV will 'think of' incoming integer fields as binary, and then will redefine them in the program structures as PACKED. So, when you chain a record... Continue Reading
When AS/400 running STOP gives the error message 'Space offset X'0015FF00' or X'0000000000000000' is outside current limit for object QIGC2424C', the... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.