Ask the Expert

Monitoring escape messages and using RCVMSG for diagnostic messages

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.
  1. The image catalog entry may already exist (same CD inserted twice)
  2. The image file was not deleted on the IFS
  3. 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
GOTO CMDLBL(CD1CONT)

Solution:

MONMSG     MSGID(CPFBC28) EXEC(DO)
RCVMSG     MSGTYPE(*DIAG) MSGID(&MGID)
    IF         COND(&MGID *EQ 'CPDBC19') THEN(GOTO

CMDLBL(IMGFEXT1))
    IF         COND(&MGID *EQ 'CPDBC29') THEN(GOTO

CMDLBL(IMGCEXT1))
  GOTO       CMDLBL(NOCD1)
       ENDDO
  GOTO       CMDLBL(CD1CONT)

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: