Correct severe misconception about SetCurrentKey in the knowledge base

This commit is contained in:
Djordje Cenic 2026-08-22 12:04:00 +02:00
parent 841b4e7cab
commit 6e321d3c56
6 changed files with 74 additions and 40 deletions

View file

@ -0,0 +1,18 @@
codeunit 50230 "Perf Sample SetCurrentKey Good"
{
// SetCurrentKey is used because the rows must be processed oldest-first.
// The sort is a functional requirement, so the ORDER BY it adds is justified.
procedure ApplyOldestEntriesFirst(CustomerNo: Code[20])
var
CustLedgerEntry: Record "Cust. Ledger Entry";
begin
CustLedgerEntry.SetRange("Customer No.", CustomerNo);
CustLedgerEntry.SetRange(Open, true);
CustLedgerEntry.SetCurrentKey("Posting Date");
if CustLedgerEntry.FindSet() then
repeat
// Apply entries in posting-date order ...
until CustLedgerEntry.Next() = 0;
end;
}