Array Report

madmmadm Member Posts: 92
edited 2007-02-21 in Navision Attain
I am trying to create a report which shows 3 periods of consumption. The period is determined by the user.

I have looked at some reports to get an idea of how to do this, and came up with the following :

2 dataitems : item and item ledger entry : i have linked, and put filters on as required. ON the item ledger entry i have put the following :
OnPreDataItem()
CurrReport.CREATETOTALS(TotalInvtQty,InvtQty);

"Item Ledger Entry".SETFILTER("Posting Date",'>%1',ILEFilter);

OnAfterGetRecord()
Window.UPDATE(2,"Posting Date");


FOR i := 1 TO 3 DO
  IF ("Posting Date" >= PeriodStartDate[i]) AND
    ("Posting Date" < PeriodStartDate[i + 1])

  THEN BEGIN
    InvtQty[i] := Quantity;
    IF InvtQty[i] <> 0 THEN
      PrintLine := TRUE;
   Test := PeriodStartDate[4] + 1;
  END;


When for example the user puts ending date = 20/02/07 the report runs ok, but the entries for 20/02/07 are not included in the totals. In the code I see there is "posting date" < periodstart date.. I tried to change this to =< but which cured it, but when running for 1D period length, this messed the figures up.

Can any one throw some advice on this one?

THanks :)
[/code]

Comments

  • kinekine Member Posts: 12,562
    Try to split the date array into StartDate and EndDate array with values like:

    StartDate EndDate
    01/01/07 20/01/07
    21/01/07 .....

    and use the limits including the boundaries (>= StartDate & <=EndDate)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • madmmadm Member Posts: 92
    kine wrote:
    Try to split the date array into StartDate and EndDate array with values like:

    StartDate EndDate
    01/01/07 20/01/07
    21/01/07 .....

    and use the limits including the boundaries (>= StartDate & <=EndDate)


    thanks for the reply :) following your suggestion, i came up with the following, and it appears to have worked :D

    Thats something else Ive learnt today!
    FOR i := 1 TO 3 DO
      IF ("Posting Date" >= PeriodStartDate[1]) AND
        ("Posting Date" <= PeriodStartDate[2])
      THEN BEGIN
        InvtQty[1] := Quantity;
      END;
    
      IF ("Posting Date" > PeriodStartDate[2]) AND
        ("Posting Date" <= PeriodStartDate[3])
      THEN BEGIN
        InvtQty[2] := Quantity;
      END;
    
      IF ("Posting Date" > PeriodStartDate[3]) AND
        ("Posting Date" <= PeriodStartDate[4])
      THEN BEGIN
        InvtQty[3] := Quantity;
      END;
    
    IF InvtQty[i] <> 0 THEN
       PrintLine := TRUE;
    
    
    [/code]
  • kinekine Member Posts: 12,562
    If your problem is solved, do not forget to add [SOLVED] prefix into first post subject. Thanks 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.