WITH SalesPrice DO BEGIN //>>Dilip 27Nov2009 //FoundSalesPrice := FINDSET; FoundSalesPrice := FINDFIRST; ASCENDING(FALSE); //<<Dilip 27Nov2009 IF FoundSalesPrice THEN REPEAT IF IsInMinQty("Unit of Measure Code","Minimum Quantity") THEN BEGIN ConvertPriceToVAT( "Price Includes VAT",Item."VAT Prod. Posting Group", "VAT Bus. Posting Gr. (Price)","Unit Price"); ConvertPriceToUoM("Unit of Measure Code","Unit Price"); ConvertPriceLCYToFCY("Currency Code","Unit Price"); CASE TRUE OF ((BestSalesPrice."Currency Code" = '') AND ("Currency Code" <> '')) OR ((BestSalesPrice."Variant Code" = '') AND ("Variant Code" <> '')): BestSalesPrice := SalesPrice; ((BestSalesPrice."Currency Code" = '') OR ("Currency Code" <> '')) AND ((BestSalesPrice."Variant Code" = '') OR ("Variant Code" <> '')): IF (BestSalesPrice."Unit Price" = 0) OR (CalcLineAmount(BestSalesPrice) > CalcLineAmount(SalesPrice)) THEN BestSalesPrice := SalesPrice; END; END; UNTIL NEXT = 0; END;This code is in Codeunit 7000 Sales Price Calc. Mgt.\CalcBestUnitPrice(SalesPrice).
Answers
As your sorting is DESCENDING you UNTIL NEXT = 0; statement should be NEXT(-1) = 0;
Hope this helps.
Albert
I just missed my focus at that line of Next = 0;
Yes, As I am desending the sort, Next(-1) = 0 should be the condition to add it there. It works fine now.
Thanks again.
Falling down is not a defeat..defeat is when you refuse to get up.
This loop finds the best sales price and IMHO it does not matter if you start at the bottom or beginning.
Just Curious.
Oh, and change the FINDFIRST to a FIND('-') please.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!