myITforum and Windows IT Pro Forums
Forum Themes:
Welcome !

 Removing messages from *MSGQ using QMHRMVPM

Author Message
xrunner

  • Total Posts : 8
  • Scores: 0
  • Reward points : 1510
  • Joined: 4/6/2017
  • Status: offline
Removing messages from *MSGQ using QMHRMVPM Wednesday, June 21, 2017 5:32 PM (permalink)
0
I'm working on a program that will scan all the source files on our system for a given argument. This is similar to FNDSTRPGM except it scans numerous files and the output goes to a file instead of a *SPLF. The program works great but there are thousands of members being opened because the source files are overridden to *ALL members. This causes the job *MSGQ to wrap. Add to the problem, I have hundreds of scans that I need to perform so I'm wrapping the RPG program with another program to perform all the scans in a single job. The *MSGQ continues to wrap and QSYSOPR gets a message each time it happens.
 
What I'm trying to do is clear the *MSGQ using the api QMHRMVPM, but I haven't been able to get it to work. Here's the code I've currently got:
Dcl-Proc rmvMsgs; 
 /include qsysinc/qrpglesrc,qusec 
 Dcl-pr qmhrmvpm extpgm('QMHRMVPM');   
   CallStackEntry    varchar(65535) const;   
   CallStackCount    int(10)        const;   
   MsgKey            char(4)        const;    
   MsgToRemove       char(10)       const;   
   ApiErrorDS        likeds(qusec)  const; 
 End-pr;
  qusbprv = 1; 
   qmhrmvpm('*':0:*BLANKS:'*ALL':'*');
   qmhrmvpm('*EXT':0:*BLANKS:'*ALL':'*');
   qmhrmvpm('*ALLINACT':0:*BLANKS:'*ALL':'*');
   qmhrmvpm('QDBGETM':0:*BLANKS:'*ALL':'*');
   qmhrmvpm('QDBSEQMP':0:*BLANKS:'*ALL':'*');
   qmhrmvpm('QDBOPEN':0:*BLANKS:'*ALL':'*');
 End-proc;
 

 
The messages I'm trying to remove are:
 
MSGID      TYPE                    SEV  DATE      TIME             FROM PGM     LIBRARY     INST     TO PGM      LIBRARY     INST
 CPI5209    Information             00   06/21/17  15:54:43.929122  QDBSEQMP     QSYS        012D     QDBGETM     QSYS        110E
 Message . . . . :   Moved from member DDRLL066P to member DDRLL067.                         
 CPF4011    Diagnostic              10   06/21/17  15:54:45.085723  QDBOPEN      QSYS        *STMT    QDBSEQMP    QSYS        0203
 From module . . . . . . . . :   QDBOPEN
 From procedure  . . . . . . :   SGNRTNOK
 Statement . . . . . . . . . :   15430
 Message . . . . :   Buffer length longer than record for member DDL00016.

 
Does anybody have some good advice on how to make it work? As you can see from the numerous calls to QMHRMVPM, I've resorted to blind attempts trying to find the correct parameters. I have searched the internet for a solution, but none of them have worked for me.
 
#1
    jsev

    • Total Posts : 24
    • Scores: 2
    • Reward points : 44300
    • Joined: 11/19/2015
    • Status: offline
    Re:Removing messages from *MSGQ using QMHRMVPM Thursday, June 22, 2017 4:59 PM (permalink)
    0
    I was going to ask what error the API is returning, however as the error code parameter has not been correctly setup, you won't have access to this information.  I think the first thing you should do is correctly setup the error code.  The error code parameter is not a constant, the system returns details of the error to this and it could be the cause of the API failure.
    So, first I'd remove the Const keyword from ApiErrorDS.
    2nd, I'd define qusbprv = %Size(qusec) to correctly set the size.  Note that the qusec includes don't include the data portion of the error, just the fixed length.  I personally create my own error code DS and use that as the qsysinc includes are horribly defined.
    3rd I'd pass qusec to the API.  This way, if it errors, QUSEI will contain the error code received which you can match to the errors in the API documentation.
    That will give you a starting point to the errors or may even fix the problem.
     
    #2
      xrunner

      • Total Posts : 8
      • Scores: 0
      • Reward points : 1510
      • Joined: 4/6/2017
      • Status: offline
      Re:Removing messages from *MSGQ using QMHRMVPM Friday, June 23, 2017 9:46 AM (permalink)
      0
      Thanks for responding.
      I went ahead and created my own error DS as shown below. Let me know if I still haven't fixed everything I should have corrected.
      The results in "ErExcptDta" are blank and the *MSGQ is still wrapping.
       
       Dcl-pr qmhrmvpm extpgm('QMHRMVPM');
         CallStackEntry    char(10)   const;
         CallStackCount    bindec(8)  const;
         MsgKey            char(4)    const;
         MsgToRemove       char(10)   const;
         ApiErrorDS like(ErrCdDS);
       End-pr;
       
      Dcl-ds ErrCdDS;
         ErByteProv  bindec(9);
         ErByteAval  bindec(9);
         ErExceptId  char(7);
         ErReserved  char(1);
         ErExcptDta  char(100);
       End-ds;
       
      clear ErrCdDS;
       ErByteProv = %size(ErrCdDS);
       qmhrmvpm('*':0:*BLANKS:'*ALL':ErrCdDS);
       

       
      #3
        xrunner

        • Total Posts : 8
        • Scores: 0
        • Reward points : 1510
        • Joined: 4/6/2017
        • Status: offline
        Re:Removing messages from *MSGQ using QMHRMVPM Friday, June 23, 2017 10:07 AM (permalink)
        0
        By changing the API call I was able to clear the *MSGQ and eliminate the wrapping issue! Here's the code that works:
         
         Dcl-pr qmhrmvpm extpgm('QMHRMVPM');
           CallStackEntry    char(10)   const;
           CallStackCount    bindec(8)  const;
           MsgKey            char(4)    const;
           MsgToRemove       char(10)   const;
           ApiErrorDS like(ErrCdDS);
         End-pr;
         
        Dcl-ds ErrCdDS;
           ErByteProv  bindec(9);
           ErByteAval  bindec(9);
           ErExceptId  char(7);
           ErReserved  char(1);
           ErExcptDta  char(100);
         End-ds;
         
        clear ErrCdDS;
         ErByteProv = %size(ErrCdDS);
         qmhrmvpm('*ALLINACT':0:*BLANKS:'*ALL':ErrCdDS);
         

         
        With that working, is there an easy way to remove only the two errors shown in my 1st post? It might be good to see other errors if any occur.
         
        #4
          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2017 ASPPlayground.NET Forum Version 3.9