Q

Monitoring escape messages and using RCVMSG for diagnostic messages

When an error occurs on an IBM command, the diagnostic messages are sent first, then an escape message, which you can monitor. On AS/400 you see the escape message, and then you use the RCVMSG command to get the last diagnostic message sent to your program. Expert John Blenkinsop provides the code needed to monitor the diagnostic messages after receiving an escape message.

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

Dig deeper on iSeries programming commands

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

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:

SearchEnterpriseLinux

SearchDataCenter

Close