Cust. Ledger Entry - OnPreDataItem() //"Cust. Ledger Entry".SETFILTER("Posting Date",DateFilt); FinchargeTotal:=0; PrincipalTotal:=0; ArreasVarTotal:=0; CustBal1 := 0; TotCustBal1:=0; NumPayments := 0; //GTotArrs := 0; GPrincipalTotal := 0; Cust. Ledger Entry - OnAfterGetRecord() Fincharge:=0; Principal:=0; ArreasVar:=0; CustBal :=CustBal+"Cust. Ledger Entry".Amount; TotalCustBal := "Detailed Cust. Ledg. Entry"."Amount (LCY)"; CustBal1 := "Cust. Ledger Entry". Amount; //CustBal :=CustBal + "Cust. Ledger Entry". Amount; TotCustBal1 += CustBal1; //Code to count no. of payments IF "Document Type"="Document Type"::Payment THEN BEGIN NumPayments := NumPayments +1; END; //IF Amt = 0 THEN // CurrReport.SKIP; IF "Document Type"="Document Type"::Payment THEN BEGIN // NumPayments := NumPayments +1; Principal:= "Closed by Amount"; Fincharge :=ABS(Amount)-ABS(Principal); FinchargeTotal:=FinchargeTotal+ ABS(Fincharge); PrincipalTotal :=PrincipalTotal+ABS(Principal); ArreasVar:= -Customer."Monthly Install" - "Cust. Ledger Entry".Amount; ArreasVarTotal:=ArreasVarTotal+ArreasVar; END; TotalCustBal := "Detailed Cust. Ledg. Entry"."Amount (LCY)"; FromDate := 010107D; ToDate := "Posting Date"; Amount := 0; CustLedEntryMonth := ''; MonthsArrears := 0; //Code to Count Months IF (FromDate <> 0D) AND (ToDate > FromDate) THEN BEGIN Calendar.RESET; Calendar.SETRANGE("Period Type",Calendar."Period Type"::Month); Calendar.SETRANGE("Period Start",FromDate,ToDate); Months := Calendar.COUNT; END ELSE Months := 0; MonOwed:= Months - NumPayments; OtherArrears := MonOwed * -Customer."Monthly Install"; TotArrs := OtherArrears + ArreasVarTotal; GTotArrs += TotArrs; GTotCustBal1 += TotCustBal1; GPrincipalTotal += PrincipalTotal; GFinchargeTotal += FinchargeTotal;The above last four code are suppose to do the summing.
Answers
there is a whole section about Grouping & Totaling?
have you defined any CREATETOTALS, TOTALFIELDS or GROUPTOTALFIELDS?
see C/side help for more
http://www.BiloBeauty.com
http://www.autismspeaks.org
I called the field Acc. Amount. Under this field we have the total amounts which are calculated from fields like Monthly install which is from the customer table. the below code is the code that does the calculation:
The fields FinchargeTotal,PrincipalTotal,TotCustBal1 and TotArrs are the fileds i want to total. Already they are all totals from calculation.
Now i want to total them for each customer so that i can have a grand total for each customer.
The fields: GTotArrs ,GTotCustBal1,GPrincipalTotal and GFinchargeTotal are defined in the global variable so that i can use them as fields for the result of the calculation i will get from the formulas below:
GTotArrs += TotArrs;
GTotCustBal1 += TotCustBal1;
GPrincipalTotal += PrincipalTotal;
GFinchargeTotal += FinchargeTotal;
So they are not fields in the Cust. ledger Entry Table which i am using as one of the dataitems. Therefore i can't define them under the Grouptotals and Total fields in the properties of the Cust. Ledger Entry. The other dataitem i am using is Customer table.
Did anyone have a suggestion that can be a solution to my problem? I need you suggestions Please!!! (*,)
Thanks.
Use the CurrReport.CREATETOTALS(GTotArrs,.....,GFinchargeTotal); in the PreDataItem section.
Hope this helps.
Albert
I have finally solved it by putting the codes calculating the grand totals at the PostDataitem trigger and initialising the required variables.
Thanks for your ideas it really gave me some hint.
Remember that most of the fields of the Customer Ledger Entry table are flowfields so you must do a CALCFIELDS in the OnAfterGetRecord
Albert
Hi Kolaboy,
Albert's solution is the correct and proper way to do this. My guess is that you forgot to insert the correct Group Totals section to display the results.