CL400 Monmsg CPF0000 vs CPF9999 - skill-at/AS-400-Training GitHub Wiki

First, we can monitor for a specific message, e.g.

MONMSG    MSGID (CPF9821)

Or we can monitor for a list of messages, e.g.

MONMSG    MSGID (CPF9821 CPF9822 ……  CPF9830)

Now if we want to catch all the messages that start with CPF98.., then we can go for the below MONMSG:

MONMSG MSGID (CPF9800)

Now if we want to catch all the possible generic messages for CPF…., we can use the below MONMSG:

MONMSG MSGID (CPF0000)

To have more generic message monitor, we can go for:

MONMSG MSGID (CPF0000 MCH0000) EXEC (GOTO ERROR)

But now suppose we have given the generic message handling MONMSG command as above, but the program generates a message that is not in this generic list of messages then that will not be handled.

That unhandled message is converted into CPF9999 by our system automatically.

Hence, all the unhandled messages are converted to CPF9999, which actually is being handled by our generic MOMSG command.

Example

Suppose there is any program which needs parameter value (file name) to be passed and it deletes file based on parameter received , but somehow we are not passing the value in this case ,we get an error CPD0071. Hence, here this unhandled exception is converted to CPF9999 and then it is handled via CPF0000(GENERIC MSG HANDLER).