× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I wonder if we're looking at this differently because my response is, "Yeah it'll remove everything." It has to work that way. You have to get the "from message key" before you encounter the anticipated error, the way I understand it.

Would it help to see the actual code?

Monitor;
MsgKey = $getCurrentMessageKey();
Write PreviousFile;

// If a duplicate key was found, remove the error messages.
On-Error ERR_DUPLICATE_KEY;
$RemoveJobLogEntriesByKey( MsgKey );
EndMon;

-Kurt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Monday, June 28, 2010 1:04 PM
To: RPG programming on the IBM i / System i
Subject: Re: Removing Job Log Messages

Kurt

Glad to hear this did the job for you.

One caveat - this will remove everything between the first bracketing
message and the second one. You might want to keep some messages, so you
may need to put in conditions for that kind of thing.

Vern

On 6/28/2010 10:51 AM, Kurt Anderson wrote:
Finally, success.

The article that Vern provided was really the answer. In order to get rid of that Sender's Copy, and even the system reply, I needed to use the retrieve the Message Key and remove job log entries by Message Key.

Since the article didn't have an RPGLE example, and likewise didn't mention that unlike the CL API calls, RPGLE has to monitor for CPF2410, I thought I'd share the code I came up with. (Oh, and there was also the issue of casting that the article used that I had to convert to RPGLE.)

And again, here's the article link:
https://www-912.ibm.com/s_dir/slkbase.NSF/1ac66549a21402188625680b0002037e/87d6dce3b5ab62c486256c8b005acd11?OpenDocument

Example use of the procedures:
Monitor;
CurrentMessageKey = $getCurrentMessageKey();
[logic that may error]
On-Error [handled error];
$RemoveJobLogEntriesByKey( CurrentMessageKey );
EndMon;

And here's the code taken from the service program. The $RemoveJobLogEntries() procedure could be tweaked a bit more in regard to its error handling. Also, I made some local variables static due to the potential high volume of procedure calls that could occur.

D ApiErrorDS DS Inz
D ErrBytPrv 10i 0 Inz( %size( ApiErrorDS ) )
D ErrBytAvl 10i 0
D ErrMsgID 7a
D 1a
D ErrMsgDta 256a

// Receive Program Message API Prototype
D QMHRCVPM PR extpgm( 'QMHRCVPM' )
D ReceiveVar 32767a options( *varsize )
D ReceiveVarLen 10i 0 const
D Format 8a const
D StackEntry 4096a Const Options( *varsize )
D StackCount 10i 0 Const
D MessageType 10a const
D MessageKey 4a const
D WaitTime 10i 0 const
D Action 10a const
D ds_Error options( *varsize )
D Like( ApiErrorDS )

// Remove Program Message API Prototype
D QMHRmvPM pr ExtPgm( 'QMHRMVPM' )
D StackEntry 4096a Const Options( *varsize )
D StackCount 10i 0 Const
D MessageKey 4a Const
D MessageID 10a Const
D ds_Error Options( *varsize )
D Like( ApiErrorDS )

// Send Program Message API Prototype
D QMHSNDPM PR ExtPgm( 'QMHSNDPM' )
D MessageID 7A Const
D MessageFile 20A Const
D MessageData 32767A Const Options( *varsize )
D MessageDataLength...
D 10i 0 Const
D MessageType 10A Const
D StackEntry 4096a Const Options( *varsize )
D StackCount 10i 0 Const
D RtnMessageKey 4A
D ds_Error Options( *varsize )
D Like( ApiErrorDS )

//=======================================================================*
// Get the Current Message Key value *
// *
// Parameters: *
// Input - n/a *
// Output - n/a *
// *
// Return Value: Message Key *
// *
//-----------------------------------------------------------------------*
P $getCurrentMessageKey...
P B Export
D PI 4a

// General API Error Data Structure
D ds_ApiError DS Static LikeDS( ApiErrorDS )

// Local Constants
// Local Variables
D rtnMsgKey S Static Like( $getCurrentMessageKey )
//-----------------------------------------------------------------------*
/Free

QMHSNDPM( *blanks: *blanks: 'TEST': 4: '*INFO': '*': 0: rtnMsgKey:
ds_APIError );

QMHRMVPM( '*': 0: rtnMsgKey: '*BYKEY': ds_APIError );

Return rtnMsgKey;

/End-Free
P $getCurrentMessageKey...
P E
//-----------------------------------------------------------------------*


//=======================================================================*
// Procedure: $RemoveJobLogEntriesByKey *
// Description: Remove Job Log Entries by Key *
// *
// Notes: The caller should have called $GetCurrentMessageKey *
// prior to an anticipated error. That Message Key is *
// what should be passed into this procedure. *
// The Procedure will remove all job log entries after *
// the key provided. *
// *
// Parameters: *
// Input - Message Key Before Expected Error *
// Inp/Out - n/a *
// Output - n/a *
// *
// Return Value: n/a *
// *
//-----------------------------------------------------------------------*
P $RemoveJobLogEntriesByKey...
P B Export
D PI
D BeforeKey 4a Const

// General API Error Data Structure
D ds_ApiError DS Static LikeDS( ApiErrorDS )

// Local Data Structures
D ds_MsgKey DS Qualified Based( TEMPLATE )
D MsgKey 4a
D MsgKey# 10i 0 Overlay( MsgKey )

D ds_Before DS Static LikeDS( ds_MsgKey )
D ds_High DS Static LikeDS( ds_MsgKey )
D ds_New DS Static LikeDS( ds_MsgKey )

// Local Constants
// Local variables
D MsgInfo S 8a Static

//-----------------------------------------------------------------------*
/free

ds_Before.MsgKey = BeforeKey;

// Get the latest MessageKey
ds_High.MsgKey = $getCurrentMessageKey();

// Remove every message after the Before Message Key up to and
// including the Last message key encountered.
For ds_New.MsgKey# = (ds_Before.MsgKey# + 1) to ds_High.MsgKey#;

// Since we're looping through each possible message key, we need
// to monitor in case the message key doesn't exist.
Monitor;
QMHRmvPM( '*': *zero: ds_New.MsgKey: '*BYKEY': ds_APIError );
On-Error;
EndMon;
EndFor;

// Remove all messages created by this procedure, which should be
// messages saying that a message key wasn't found.
QMHRmvPM( '*': 0: *blanks: '*ALL': ds_APIError );

Return;

/end-free
P $RemoveJobLogEntriesByKey...
P E
//-----------------------------------------------------------------------*

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Friday, June 25, 2010 12:28 PM
To: RPG programming on the IBM i / System i
Subject: Re: Removing Job Log Messages

Cool! I'm going to guess that processing messages by key has to be
pretty efficient, and it does let you clean up all kinds of non-error
errors.

Vern

On 6/25/2010 11:57 AM, Kurt Anderson wrote:

My bad, Vern. This article does apply. A thousand apologies. ;) Although I'm still debating whether or not the solution is right for my high-volume processing environment. For example, if I process 60 million records, I'd be essentially writing to the job log 60 million times, then removing it 60 million times, just to get the message key. Ideally, we only ever have a couple thousand duplicates we're concerned with. (Although in the last batch, we had 3.8 million which is why the Sender's Copy became an issue.)

I'll do some testing to see just how much of an impact the extra steps would be.

Thanks!
Kurt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kurt Anderson
Sent: Friday, June 25, 2010 9:38 AM
To: 'RPG programming on the IBM i / System i'
Subject: RE: Removing Job Log Messages

Hi Vern,

Thanks for the link. Looks like it has to do with program-to-program message sending and using the message key. I'm trying to capture a system message.

Yesterday I thought it'd be ok to have that lone Sender Copy message, but as I learned today, it's still too much. Our client gives us a huge chunk of data and says, "Here." Well, 100,000+ were duplicates and caused our job to bomb b/c we don't wrap the job log. To get this through I will wrap the job log, but it would be ideal to remove this system message.

Thanks,
Kurt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Thursday, June 24, 2010 4:36 PM
To: RPG programming on the IBM i / System i
Subject: Re: Removing Job Log Messages

Kurt

IBM put out a knowledge base article that might help you here. I don't
know if it works with Sender Copy, but it might be worth a look.

The title is "*Receiving Messages from the Joblog after the Program Is
off the Callstack"*

And a link to it is *http://tinyurl.com/d4a6xx*

The article has examples in C and in CL - easily enough fitted to RPG.

HTH
Vern

On 6/24/2010 4:09 PM, Kurt Anderson wrote:


I created a service program called $RemoveProcedureJobLogEntries().
It will attempt to remove all messages generated by the calling procedure using the QMHRMVPM API by using the *ALL remove code. Unfortunately, this isn't capturing the "SENDER COPY." I understand why it's not - in looking at the job log, all of the other messages are TO the Module& Procedure (which I have specified in the API call), but SENDER COPY does not have this information.

So I'm left wondering, how can I remove this message as well? Ultimately, I'm happy with what the API does for me already, but it would be nice to remove this message as well.

Full information about the message I want to remove:
CPF5026 Sender copy 30 06/24/10 10:37:31.651168 QDBSIGEX QSYS 01EA QDBSIGEX QSYS 01EA
Message . . . . : Duplicate key not allowed for member EQNFMTPP.
Cause . . . . . : An output or update operation on member EQNFMTPP failed
because of a duplicate key in member EQNFMTPP file EQNFMTPP in library
KJA9LIB. Recovery . . . : See previously listed message CPF5009 to
identify the record with the duplicate key. Then change the key value so
that each key is unique and try your request again. Possible choices for
replying to message . . . . . . . . . . . . . . . : C -- The request is
canceled. I -- The request is ignored.

And for the record, this error is handled by the program, so I don't want the job log to be potentially bogged down by it (there are other things in the job log we'd rather see w/o having to work our way through this stuff).

Thanks,
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems



--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.