How to Sum By Customer Posting Group.

kolaboykolaboy Member Posts: 446
Hi
I am trying to sum customers total balances by Posting Group. Here is a code i wrote but it not working. can someone help me with this.
IF Customer."Customer Posting Group" = 'BAK' THEN BEGIN
IF Customer."Monthly Install" <> 0 THEN BEGIN
   //BAKTotalCustBal := "Detailed Cust. Ledg. Entry"."Amount (LCY)";
   BAKCustBal1 := "Cust. Ledger Entry". Amount;
   BAKArreasVar:= -Customer."Monthly Install" - "Cust. Ledger Entry".Amount;
END;
END;
BAKArreasVarTotal:=ArreasVarTotal+BAKArreasVar;
BAKTotCustBal1 += BAKCustBal1;
END;

I need it like this
BAK
20000 i.e the total arrears for all the customers with Posting group of BAK
BRDAL
48090
BTU......................32090 ans so on

I am to create a report to display the information as above.
Can somone help me Please.
Thanks

Comments

  • KarenhKarenh Member Posts: 209
    The Cust. Ledger Entry table Amount field is a flowfield. To have it populated with the amount you must
    "Cust. Ledger Entry".CALCFILELDS(Amount);

    Then you can add the amount to your variable.

    But a more efficient way of getting the customer balance is
    Customer.CALCFIELDS(Balance);
  • kinekine Member Posts: 12,562
    Yes, you can use the Balance field and you can use the CREATETOTALS on the report to calc the totals. Search for the CREATETOTALS and how to use it in Manual or on the forum.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • siyaksiyak Member Posts: 66
    Hi there its better to use the Rec.Calcfields(Amount) or the CREATETOTALS on the OnPreDataItem
  • kinekine Member Posts: 12,562
    siyak wrote:
    Hi there its better to use the Rec.Calcfields(Amount) or the CREATETOTALS on the OnPreDataItem

    The commands are for totaly different purpose there... you cannot ask "what is better"... you need CALCFIELDS to cal correct value of the flowfield, you need CREATETOTALS to create totals of some variable/field...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.