Top 10 report show item rank that entry type as consumption.

klumklum Member Posts: 102
I make a new this top 10 report by save as Inventory - Top 10 List.

So I change source expression of text box from Item.Inventory to Qty and insert some code like this
CLEAR(Qty);
IF Item.Inventory <> 0 THEN BEGIN
  ItemLedgEntry.RESET;
  ItemLedgEntry.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Drop Shipment","Location Code","Posting Date");
  ItemLedgEntry.SETRANGE("Entry Type",ItemLedgEntry."Entry Type" :: Consumption);
  ItemLedgEntry.SETRANGE("Item No.",Item."No.");
  IF ItemLedgEntry.FIND('-') THEN  BEGIN
    REPEAT
      Qty += ItemLedgEntry.Quantity;
    UNTIL ItemLedgEntry.NEXT = 0;
  END;
END;

ItemAmount.INIT;
ItemAmount."Item No." := "No.";
IF ShowType = ShowType::"Sales (LCY)" THEN BEGIN
  ItemAmount.Amount := "Sales (LCY)";
  ItemAmount."Amount 2" := Qty;
END ELSE BEGIN
  ItemAmount.Amount := Qty;
  ItemAmount."Amount 2" := "Sales (LCY)";
END;

But something wrong because results of Qty is same every rank in spite of I CLEAR already , Why why why , What wrong i did????[/code]

Comments

  • kinekine Member Posts: 12,562
    1) I do not know, why you are calc sum only for consumption and using "Sales (LCY)" in conjunction with this quantity...

    2) Are you sure, that you calc the value Item.Inventory before you use it? (Item.Calcfields(Inventory))

    3) It is same - it means still 0 or something other?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • klumklum Member Posts: 102
    3) it's not 0 but if item rank no.1 is 999 other rank is 999.
  • kinekine Member Posts: 12,562
    Than it seems, that the Item variable is not updated in correct way...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ngebhardngebhard Member Posts: 127
    We had a similar problem a couple of days ago. We cleared the variable but that didn't work. After putting a RESET and an INIT on the use table as well, the procedure worked! Doesn't really make sense and I still don't know why this happened, but maybe should have a try.

    Greetz
    Nicole
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • kinekine Member Posts: 12,562
    After revising the klums' report, it was problem of used code. May be that Klum will say you more... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ngebhardngebhard Member Posts: 127
    Maybe I should ask to see if there is a similar problem in our coding. I didn't see it but you never know!

    Thanks for the hint! :D
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • klumklum Member Posts: 102
    at the end of the Integer - OnAfterGetRecord
    IF ShowType = ShowType::"Sales (LCY)" THEN
      Qty := ItemAmount."Amount 2"
    ELSE
      Qty := ItemAmount.Amount;
    

    now It's work well

    Thank a lot for Arhontis and kine. :)

    klum
Sign In or Register to comment.