× 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.



Use a DOU loop. Add 1 year to the hire date until the result (review
date) is greater than today's date. After the loop, check to see if
today's date is <= 1 month from today.

Francis Lapeyre
IS Dept. Programmer/Analyst
Stewart Enterprises, Inc.
E-mail: flapeyre@xxxxxxxx 


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kim Spears
Sent: Thursday, November 9, 2006 10:13 AM
To: RPG400-L@xxxxxxxxxxxx
Subject: How to select for future event

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?

Here is what I have done so far:

*************** Beginning of data
*****************************************
H dftactgrp(*no) bnddir('BINDDIR')

FDB2FILE   IF   E           K DISK

FQPRINT    O    F  198        PRINTER

 /COPY QSOURCE,$DATE_P

D compareDate     S               D

D compareYear     S              4  0

D fileDate        S               D

D fileYear        S              4  0

D runDate         S               D   INZ(D'2006-01-01')

 

C                   DO        365

C                   EVAL      compareDate = runDate + %MONTHS(1)

C                   EVAL      compareYear = %subdt(compareDate : *YEARS)

C                   EXSR      $runDate

C                   EVAL      runDate += %DAYS(1)

C                   ENDDO

 

C                   EVAL      *INLR = *ON

 
************************************************************************
**
C     $runDate      BEGSR

 

C     *LOVAL        SETLL     DB2FILE                            99

C                   READ      DB2FILE                                99

 

C                   DOW       ( *IN99 = *OFF)

 * Convert file date format to ISO format.

C                   EVAL      fileDate = $D5toISO(ehdate)

C                   EVAL      fileYear = %subdt(fileDate : *YEARS)

 

C                   IF        ( fileYear < compareYear )

 

 * Synchronize years so comparison can be made

C                   EVAL      fileDate += %YEARS(compareYear - fileYear)

C                   IF        ( fileDate = compareDate )

C                   EXCEPT    LINE

C                   ENDIF

 

 * If September, April, June or November... extend comparison to 31 days

C                   IF        ( %subdt(runDate : *MONTHS) = 9 ) OR

C                             ( %subdt(runDate : *MONTHS) = 4 ) OR     
C                             ( %subdt(runDate : *MONTHS) = 6 ) OR     
C                             ( %subdt(runDate : *MONTHS) = 11 )       
C                   IF        ( %subdt(runDate : *DAYS) = 30 ) AND     
C                             ( fileDate = compareDate + %DAYS(1) )    
C                   EXCEPT    LINE                                     
C                   ENDIF                                              
C                   ENDIF                                              
                                                                       
C                   ENDIF                                              
                                                                       
C                   READ      DB2FILE                                99
C                   ENDDO                                              
                                                                       
C                   ENDSR                                              
 ******                                                                
OQPRINT    E            LINE       01                                  
O                       FName               16                         
O                       LName               38                         
O                       HDate               46                         
O                       runDate             65
O                       compareDate         87
****************** End of data
********************************************

 


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.