On 07/10/2008, at 12:04 AM, David FOXWELL wrote:
I'm having problems with messages.
I want to check for an escape message and then send that message to  
the caller.
If I code RCVMSG MSGTYPE(*EXCP), I'm getting a CPF9999. I have to  
do a second RCVMSG to get the message I'm looking for. However,  
with MSGTYPE(*ANY) my message this order seems to be inversed. *ANY  
isn't satisfactory as I'm picking up other messages not related to  
the error I'm trying to control.
Can anyone explain this and how I should be doing it ?
Working as designed and documented. MSGTYPE(*EXCP) operates in LIFO.  
Other types are FIFO.
The reason you are getting CPF9999 is because you are not monitoring  
for either a specific message or a generic message ID such as  
CPF0000. This results in the OS exception handler kicking in and  
generating a Function Check (or CPF9999). The job log contains both  
the original exception and the function check (which indicates the  
exception was not monitored).
Most people use a global MONMSG for CPF0000 but I use CPF9999 because  
I want to get a function check. It provides much more diagnostic  
information for unexpected exceptions. Expected exceptions should be  
monitored for explicitly or using a generic ID (and then removed from  
the job log). The archives are full of comments from me on the proper  
way to do exception handling. Use them.
The technique you are using to receive the first exception (CPF9999)  
and then receive the previous exception to that is the correct method  
when dealing with CPF9999.
I published a STDERR set of functions to do this probably 15 years  
ago now. They should be in the archives too but a quick search did  
not find them. I have noticed that stuff I **KNOW** exists in the  
archives cannot be found with an obvious search yet it shows up  
indirectly under other searches. Search is NOT helped by the search  
engine stripping characters it doesn't like from the search string.
Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         OS/400, i5/OS Technical Specialists
   
http://www.flybynight.com.au/
   Phone: +61 2 6657 8251   Mobile: +61 0411 091 400        /"\
   Fax:   +61 2 6657 8251                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------
 
As an Amazon Associate we earn from qualifying purchases.