25 pts.
 FNDSTRPDM – how do i find joblog
I am using FNDSTRPDM command in my CL program for each file/field and running through RPG programs if the string is found. If I specify the wrong file (QRPGLESRC) and the program is found in QRPGSRC, I get the error PDM0055, which i can monitor. However, if the program is found and the string is not, I get message '0 members match the Find string in file QCLSRC.' and message PDM0575. Unfortunately, I cannot monitor this message as it is NOT an error message. could someone tell me how I could monitor this? I am running this for a large number of fields and therefore I need my CL program to flag ones that give me message PDM0575

Software/Hardware used:
ASKED: December 22, 2010  1:58 PM
UPDATED: January 4, 2011  4:20 PM
  Help
 Approved Answer - Chosen by EmNichs

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.

Tom

ANSWERED:  Dec 28, 2010  1:14 AM (GMT)  by EmNichs

 
Other Answers:

Thanks for your help. I works great!

Last Wiki Answer Submitted:  January 4, 2011  4:20 pm  by  Dhaloo   25 pts.
Latest Answer Wiki Contributors:  Dhaloo   25 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

You can monitor for PDM0575 – it is an error message, albeit having a severity of 00 and not defined in QCPFMSG.

 5,670 pts.

 

Oops, you’re right. I didn’t look at the message type. Sorry for any confusion.

 5,670 pts.