bcquality/microsoft/knowledge/performance/calcsums-instead-of-calcfields-in-loop.bad.al
Jesper Schulz-Wedde af94c135ad Add BC performance knowledge from OptimAL learnings
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-25 14:13:37 +02:00

14 lines
469 B
AL

codeunit 50223 "Perf Sample CalcSums Bad"
{
procedure TotalSales(CustomerNo: Code[20]) Total: Decimal
var
CustLedgerEntry: Record "Cust. Ledger Entry";
begin
CustLedgerEntry.SetCurrentKey("Customer No.");
CustLedgerEntry.SetRange("Customer No.", CustomerNo);
if CustLedgerEntry.FindSet() then
repeat
Total += CustLedgerEntry."Sales (LCY)";
until CustLedgerEntry.Next() = 0;
end;
}