Monday 17 October 2011

RPGLE - Testing for valid *ISO date


    RPGLE  - Testing for valid *ISO date

D*=======================================================
     D ISODate         S               D
     D Count           S             06  0
     D MonthD          S             02  0
     D YearD           S             04  0
     D ChrMonth        S             02
     D ChrYear         S             04
     D Chr6            S             06
     C*
     C*  OLDELT is a decimal field in data file with length of 8,0
     C*  Test(de) = Test date for error if error %Error = *On
     C*
     C     *ISO          Test(de)                OLDELT     
     C                   If        Not%Error
     C     *ISO          Move      OLDELT        ISODate
     C*
     C*  Using Extrct to extract the year and month from date
     C* 
     C                   Extrct    ISODate:*M    MonthD
     C                   Extrct    ISODate:*Y    YearD
     C                   Move      MonthD        ChrMonth
     C                   Move      YearD         ChrYear
     C                   Eval      Chr6 = ChrYear + ChrMonth
     C                   Move      Chr6          YEARMONTH
     C*
     C                   Z-add     Count         LINEITEMS
     C                   If        YearD  = 2002
     C                             Or YearD = 2001
     C                             And MonthD >= 10
     C                   Write     AVERAGER
     C                   Endif
     C                   Endif
     C*=======================================================

No comments:

Post a Comment