ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Best method to Read Previous 6 records

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best method to Read Previous 6 records

    Rec Period Year Period Number Start Date End Date
    PL 5-4-4 2010 6 20100403 20100430

    PL 5-4-4 2010 7 20100501 20100604 2010 fiscal period 3
    PL 5-4-4 2010 8 20100605 20100702
    PL 5-4-4 2010 9 20100703 20100730

    PL 5-4-4 2010 10 20100731 20100903 2010 fiscal period 4
    PL 5-4-4 2010 11 20100904 20101001
    PL 5-4-4 2010 12 20101002 20101029

    PL 5-4-4 2011 1 20101030 20101203 2011 fiscal period 1

    Hi,

    I need to develop an application that gets the start and ending dates from the last two fiscal periods. If I have the current date I want to go to the current fiscal period. If my current date = 20101201 then I am in 2011 fiscal period 1. I want to read previous the 6 records and load varibles for the start and ending dates.

    Does anyone have a better mether than the read previous command?

    Thanks,

    DAC

  • #2
    Re: Best method to Read Previous 6 records

    What is the best method to read previous the 6 records or put the record pointer 6 record prior.

    Thanks,

    DAC

    Comment


    • #3
      Re: Best method to Read Previous 6 records

      Hi Dac:

      Maybe not the best method .....

      Code:
                    For x = 1 to 6;
                        readp myfile;
                    EndFor;
       
      or if you are looking for a specific key value;
       
                   setll (mykey) myfile;
                   For x = 1 to 6;
                        readpe (mykey) myfile;
                    EndFor;
      Best of Luck
      GLS
      The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

      Comment


      • #4
        Re: Best method to Read Previous 6 records

        I would develop three subprocedures to handle this:

        Subprocedure 1: Returns the fiscal period based upon the given date.
        Parms: Date Input
        Year Output
        Period Output

        Subprocedure 2: Returns the Start and End Dates for fiscal periods.
        Parms Year Input
        Fiscal Period Input
        Start Date Output
        End Date Output

        Subprocedure 3: Return The previous fiscal period
        Year Input
        Fiscal Period Input
        Previous Period Fiscal Year Output
        Previous Fiscal Period Output

        Steps:
        1) Use the first subprocedure for a give date to get the fiscal period.

        2) Take the fiscal period returned from step 1 and use subprocedure 3 to get the previous Fiscal preiod.
        3) Take the previous fiscal period in Step 2 and use subprocedure 2 to get the start and end dates.

        4) Loop thru steps 2 and 3 as many times as you need.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment

        Working...
        X