Processing data in GroupFooter or GroupHeader
vandang
Member Posts: 101
I would like to group item by Inventory posting group in Value Entry, so I decided put all text box to Group Footer (or Group Header still ok). The simple process, ex. counting line for each item worked well, report can loop through each item and show all item by group. But I want to put some code to filter data, report cannot loop, it just run at the first item and stop ](*,) . Please help!
0
Comments
-
Can you share the code and where did you write it?vandang wrote:But I want to put some code to filter data, report cannot loop, it just run at the first item and stop ](*,) . Please help!0 -
mohana_cse06 wrote:
Can you share the code and where did you write it?
Thanks for replying, I put it on Value Entry, GroupFooter - OnPreSection here is my code :STT := FALSE; IF (STT = FALSE) THEN BEGIN IF ("Invoiced Quantity" <> 0) THEN BEGIN No += 1; STT := TRUE; END; END; ItemNo := "Value Entry"."Item No."; Item.SETRANGE(Item."No.","Value Entry"."Item No."); IF Item.FINDFIRST THEN REPEAT ItemName := Item."Description 2"; UNTIL Item.NEXT = 0; //Getting GLAccount for Inventory InvPostSetup.SETRANGE("Invt. Posting Group Code", "Value Entry"."Inventory Posting Group"); IF InvPostSetup.FINDFIRST THEN InvAcc := InvPostSetup."Inventory Account"; IF (BegDat = 0D) THEN BEGIN GLEntry.SETRANGE("Posting Date",040111D,043011D); GLEntry.SETRANGE("G/L Account No.",InvAcc); IF GLEntry.FINDSET THEN REPEAT "Value Entry".SETRANGE("Entry No.",GLEntry."Value Entry No."); "Value Entry".SETRANGE("Value Entry"."Item No.",ItemNo); IF "Value Entry".FINDFIRST THEN BEGIN Adjtemp := "Adjusted Cost"; IF (GLEntry.Amount <> "Adjusted Cost") THEN BEGIN ExpectedCost := ABS("Adjusted Cost"); Adjtemp := 0; END; AdjCost := Adjtemp + ExpectedCost + AdjCost; ValQty := ValQty + "Valued Quantity"; IF ("Item Ledger Entry Type" IN ["Item Ledger Entry Type"::Purchase,"Item Ledger Entry Type"::"Positive Adjmt."]) THEN BEGIN ValueOfInvIncreases := ValueOfInvIncreases + Adjtemp + ExpectedCost; InvPosAdjustments := InvPosAdjustments + "Valued Quantity"; END ELSE BEGIN CostOfInvDecreases := CostOfInvDecreases + Adjtemp + ExpectedCost; InventoryNegAdjustments := InventoryNegAdjustments + "Valued Quantity"; END; ExpectedCost := 0; END; UNTIL GLEntry.NEXT = 0; END;
I also put the same code in Value Entry - OnAfterGetRecord, but still get the same result0 -
you are doing a FindFirst on your value entry Dataitem, Define a new record for that to use in your code. Another problem is that i think you have forgotten a BEGIN and END after you get your Inventory Posting Group.vandang wrote:mohana_cse06 wrote:
Can you share the code and where did you write it?
Thanks for replying, I put it on Value Entry, GroupFooter - OnPreSection here is my code :STT := FALSE; IF (STT = FALSE) THEN BEGIN IF ("Invoiced Quantity" <> 0) THEN BEGIN No += 1; STT := TRUE; END; END; ItemNo := "Value Entry"."Item No."; Item.SETRANGE(Item."No.","Value Entry"."Item No."); IF Item.FINDFIRST THEN REPEAT ItemName := Item."Description 2"; UNTIL Item.NEXT = 0; //Getting GLAccount for Inventory InvPostSetup.SETRANGE("Invt. Posting Group Code", "Value Entry"."Inventory Posting Group"); IF InvPostSetup.FINDFIRST THEN InvAcc := InvPostSetup."Inventory Account"; IF (BegDat = 0D) THEN BEGIN GLEntry.SETRANGE("Posting Date",040111D,043011D); GLEntry.SETRANGE("G/L Account No.",InvAcc); IF GLEntry.FINDSET THEN REPEAT "Value Entry".SETRANGE("Entry No.",GLEntry."Value Entry No."); "Value Entry".SETRANGE("Value Entry"."Item No.",ItemNo); IF "Value Entry".FINDFIRST THEN BEGIN Adjtemp := "Adjusted Cost"; IF (GLEntry.Amount <> "Adjusted Cost") THEN BEGIN ExpectedCost := ABS("Adjusted Cost"); Adjtemp := 0; END; AdjCost := Adjtemp + ExpectedCost + AdjCost; ValQty := ValQty + "Valued Quantity"; IF ("Item Ledger Entry Type" IN ["Item Ledger Entry Type"::Purchase,"Item Ledger Entry Type"::"Positive Adjmt."]) THEN BEGIN ValueOfInvIncreases := ValueOfInvIncreases + Adjtemp + ExpectedCost; InvPosAdjustments := InvPosAdjustments + "Valued Quantity"; END ELSE BEGIN CostOfInvDecreases := CostOfInvDecreases + Adjtemp + ExpectedCost; InventoryNegAdjustments := InventoryNegAdjustments + "Valued Quantity"; END; ExpectedCost := 0; END; UNTIL GLEntry.NEXT = 0; END;
I also put the same code in Value Entry - OnAfterGetRecord, but still get the same result
Furthermore, why are you using SETRANGE and FINDFIRST on primary keys ? I'd replaceItem.SETRANGE(Item."No.","Value Entry"."Item No."); IF Item.FINDFIRST THEN REPEAT ItemName := Item."Description 2"; UNTIL Item.NEXT = 0;
withIF not Item.Get("Value Entry"."Item No.") THEN Item.Init ; ItemName := Item."Description 2" ;And that also goes for when you are getting your Inventory Posting Group.0 -
Thanks MBerger,
This code is already run ok, difference is the structure of the old one is: DataItem Level
Item
Value Entry
Because user change Inventory posting group when posting, so this structure cannot get the value in Value entry table, so I just use only one Data Item is Value Entry. Here I should transfer code to this new report and don't understand why it don't loop and show all item with my code.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 324 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
