Hi guys I'm new here ...i have a doubt i have to make some vars calcs in a report
and i have to show vars in each DataItem customer process. I think i dont need CREATETOTAL NAV Function beacuse vars are not in FOOTER or GROUP Sections,
so I need help to make calcs. Here's the code..thanks.
Salesperson/Purchaser - OnAfterGetRecord()
SalesPersonCode := Code;
Customer - OnAfterGetRecord()
TotalMCurrYear := 0;
TotalMPrevYear := 0;
recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE("Sell-to Customer No.", "No.");
recSalesInvHeader.SETRANGE("Salesperson Code", SalesPersonCode);
recSalesInvHeader.SETFILTER("Due Date", '%1..%2', FInicio, FFin);
IF recSalesInvHeader.FINDSET THEN BEGIN
REPEAT
recSalesInvLine.RESET;
recSalesInvLine.SETRANGE("Document No.", recSalesInvHeader."No.");
IF recSalesInvLine.FINDSET THEN
REPEAT
TotalMCurrYear += recSalesInvLine.Amount;
UNTIL recSalesInvLine.NEXT = 0;
UNTIL recSalesInvHeader.NEXT = 0;
END;
recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE("Sell-to Customer No.", "No.");
recSalesInvHeader.SETRANGE("Salesperson Code", SalesPersonCode);
recSalesInvHeader.SETFILTER("Due Date", '%1..%2', FInicioPrevYear, FFinPrevYear);
IF recSalesInvHeader.FINDSET THEN BEGIN
REPEAT
recSalesInvLine.RESET;
recSalesInvLine.SETRANGE("Document No.", recSalesInvHeader."No.");
IF recSalesInvLine.FINDSET THEN
REPEAT
TotalMPrevYear += recSalesInvLine.Amount;
UNTIL recSalesInvLine.NEXT = 0;
UNTIL recSalesInvHeader.NEXT = 0;
END;
0
Answers
In both cases u have to add a new row at the end for totals.
First one is that you have to right click the cell go to expression and write sum(recSalesInvLine.Amount) which will do the summation for u
Second one is that you write LAST(TotalMPrevYear) which will get u the last value saved for this var
Best of luck