Report TotAmout incorrect

I make a little change on Report 202. Update a filter By Location Code and make a TotAmount Report By Location Code.

The report lines data is OK, and all lines amount are correct. But for some reason the TotAmount does not include the last report record. Why is that hapening?

MY Code

On DataItem RoundLoop add this code:

RoundLoop - OnAfterGetRecord()

// newcod (sn)

CLEAR(Localizacao);

IF SalesLine.“Location Code” <> ‘’ THEN BEGIN
Localizacao.INIT;

Localizacao.SETFILTER(Localizacao.Code,“Sales Line”.“Location Code”);
IF Localizacao.FINDSET THEN BEGIN
IF (SalesLine.“Location Code” = CodLoc) AND (SalesLine.“Location Code” <> ‘’) THEN BEGIN

REPEAT
NameE := Localizacao.Name;

TotAmount += SalesLine.Amount;

UNTIL SalesLine.NEXT=0;

END;

END;
END;

// newcod (en)

IF Number = 1 THEN
TempSalesLine.FIND(’-’)
ELSE
TempSalesLine.NEXT;
“Sales Line” := TempSalesLine;

Not sure of complete logic but I found

UNTIL SalesLine.NEXT=0; should be UNTIL Localizacao.NEXT=0;

Thanks Mohana, but the last LineAmount value is not included on the Report TotalAmount.

I can not even read the last record, that’s the problem. He is printed but not calculated. Why?

I can nor read the last record on a report.

With this function

UNTIL SalesLine.NEXT=0; the problem is not solved

You need to use UNTIL Localizacao.NEXT=0; and not

UNTIL SalesLine.NEXT=0;

Mohana

I tryed with UNTIL Localizacao.NEXT=0 but the resulkt is the same

Did you tried UNTIL Localizacao.NEXT=0; as suggested by Mohana.

Write your code after standard code please…not before the standard code…

Yes I tried, but the problem is not solved.

Can you show your whole code again and also lines in Sales Document.

TotAmount += “Sales Line”.Amount;

try this.

Use “Sales Line” in all places instead od SalesLine

Here is my Report Code and a sales order line image.

I pretend to group my report My location Code. Ant the total amount must total all lines orinted on my report Location code selection.

Thansk
Sales_Line.rar (64.1 KB)

What value do you have in CodLoc variable?

You need to Sort Sales Line on Location Code first…

Where’s the code ?

Thanks to all, with change SalesLine to “Sales Line” and put all my code after standard code the problem was solved.~

Thanks a lot

Welcome [:)]