You can monitor for PDM0575...
Unfortunately, no, you can't 'monitor' for PDM0575 because it's sent as a *DIAG message. You can only monitor for messages sent as *ESCAPE, *STATUS or *NOTIFY messages. (Both *STATUS and *NOTIFY messages may cause surprises if any are sent.)
For *DIAG (Diagnostic) messages, you need to 'receive' them instead of monitoring for them. And because there are often multiple *DIAG messages available to receive and they can't be requested by their message identifiers, you usually must receive *DIAG messages in a loop. You often then want to exit the loop after finding the one you're looking for.
Here's a sample CLLE that executes a FNDSTRPDM command and sends a 'None found.' message to the user who called the program:
pgm dcl &MsgID *char 7 dcl &KeyVar *char 4 dcl &JobUser *char 10 rtvjoba user( &JobUser ) fndstrpdm string( 'XyzAbc' ) file( mylib/QRPGLESRC ) mbr( *ALL ) + option( *NONE ) prtmbrlist( *YES) prtrcds( 1 ) rcvmsg msgtype( *DIAG ) rmv( *NO ) keyvar( &KeyVar ) msgid( &MsgID ) dountil ( &MsgID *eq ' ' ) if ( &MsgID *eq 'PDM0575' ) do sndmsg 'None found.' tousr( &JobUser ) leave /* Might as well leave since we found it... */ enddo /* Remove this ELSE after seeing the results once... */ else + if ( &MsgID *ne ' ' ) + dmpclpgm rcvmsg msgtype( *NEXT ) msgkey( &KeyVar ) rmv( *NO ) + keyvar( &KeyVar ) msgid( &MsgID ) enddo return endpgm
The first RCVMSG will find the first available *DIAG message. It returns the message identifier and the message key associated with that message.
The message key is used as a marker in the program message. The loop receives the *NEXT message after that message key and updates the key with the *NEXT key value. And that new key becomes the marker in the next iteration of the loop.
I haven't dug deeply enough to find out why the PDM0575 can't simply be received in a loop that receives straight *DIAG messages. I had to switch over to message keys after receiving the first one. It is possibly marked as an "old" message somewhere inside of FNDSTRPDM itself.
Regardless, the message key method seems to find it okay.
Thanks for your help. I works great!