|
Thanks Michael, The 365 reads was just for test purposes. I've created a small sample file to test my logic over the year. The routine in it's final version will just be run once daily. It is the suproutine logic that I am worried about. I discovered another problem with my code in that when the run date is February I wound up missing some entries at the end of March. I have corrected that, but I still have the duplicates issue. Appreciate the help, Kim -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Michael_Schutte@xxxxxxxxxxxx Sent: Thursday, November 09, 2006 12:06 PM To: RPG programming on the AS400 / iSeries Subject: Re: How to select for future event Kim, you have (in my opinion) designed this the wrong way. The way you have it designed you are going to read all the records in DB2FILE 365 times. That means if you have just 10 records in DB2FILE you'll be making 3650 reads on DB2FILE. You should have DB2FILE as your primary loop of the program, take the date on the file, use BIF %SUBDT to get the month out of the date on the file. Then compare that month to the current month. Check my syntax... I may mistakenly code something wrong. Also this is in free format but everything I use can be used in Fixed Format in at least as early as V5R1. // Get today's month, and add one CompareMnth is defined as 2,0 CompareMnth = %SubDT(%Date():*M) + 1; If CompareMnth = 13; CompareMnth = 1; EndIf; Read DB2FILE; DoW not %EoF(DB2FILE); FileMnth = %SubDT(DB2FILEDATE:*M); If FileMnth = CompareMnth; ExSr SendNotification; Endif; Read DB2FILE; EndDo; *InLR = *On; As you can see in this method that I only read DB2FILE once. If you want the program to work even faster could create a new logical that will substring the month out of the date on the file, and you can then use a keyed list to only read the month you want. Ciao! Michael Schutte rpg400-l-bounces@xxxxxxxxxxxx wrote on 11/09/2006 11:12:34 AM:
Hello Friends, I have been looking at this too long and have concluded that I may be missing something simple. My assignment is to make an application to notify supervisors that a review is due for a team member one month in the future. I have tried several approaches; the first one wound up missing team members (bad),
my current approach duplicates notice events when the previous month is longer then the succeeding month, i.e. January (better). I cannot seem to devise a simple way to filter the extra selections, which leads me to believe that I might be headed in the wrong direction entirely. It occurs to me that I may be trying to reinvent the wheel. Does anyone here have an elegant routine for matching a date in the past to
the current date plus a month, without missing or duplicating events?
-- This is the RPG programming on the AS400 / iSeries (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 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.