5038

Lock Only What You Must

read-isolation
locking
concurrency
updlock
dirty-read

Lock Only What You Must

Your warehouse runs thirty scan stations, and every parcel that crosses a belt appends one row to a shared scan ledger. The previous developer made it "safe" the pre-BC23 way: LockTable before reading the last entry number. It works — and it escalates every read for the rest of the transaction to an update lock, so thirty stations queue up behind one table lock, and the ops wallboard that only wants a rough row count stands in the same queue. Since Business Central 2023 release wave 1 the platform has a sharper instrument: the isolation level can be chosen per record instance, heightened for the one read that must lock and lowered for the one read that must never block — and the level an instance currently reads at can be read back off that instance. The grading tests do exactly that: they hand your procedures a record variable and afterwards inspect the isolation level the instance reports. A LockTable solution produces the right numbers but leaves the instance at Default — and fails.

The starter ships the finished table. Do not rename it or its fields — the tests bind to every name below character for character.

The object you get

  • Table "Scan Ledger Entry" — primary key "Entry No." (Integer); fields "Station Code" (Code[20]) and "Parcel No." (Code[20]).

Requirements

Implement all three procedures in the codeunit "Scan Ledger". Each takes the caller's record instance by var — the isolation it acquires must land on that very instance, not on a local copy.

procedure NextEntryNo(var ScanLedgerEntry: Record "Scan Ledger Entry"): Integer
procedure Append(var ScanLedgerEntry: Record "Scan Ledger Entry"; StationCode: Code[20]; ParcelNo: Code[20]): Integer
procedure EstimatedCount(var ScanLedgerEntry: Record "Scan Ledger Entry"): Integer
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 13 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade