5045

All or Nothing, Document by Document

rollback
error-recovery
batch-processing
posting

All or Nothing, Document by Document

A classic batch survives a poison record by making each finished line permanent — but that only works while every line is a single write. Tonight's job posts shipment documents that each write several records, and the 03:12 crash now leaves something worse than lost work: document 37 died after posting two of its three packages, and those two orphans are still sitting in the posted table. In this task you build the mirror-image guarantee: every document is all or nothing — a failing document vanishes without a trace, the batch keeps going, and the reason is written on the document for the morning shift.

The starter ships four finished data objects. Do not rename them or their fields — the grading tests bind to every name below character for character.

The objects you get

  • Table "Shipment Document" — primary key "Batch Code" (Code[20]) + "Document No." (Code[20]); fields Status (enum "Shipment Doc Status", defaults to Pending) and "Error Message" (Text[250]).
  • Table "Shipment Package" — primary key "Batch Code" + "Document No." + "Line No." (Integer); field Weight (Decimal).
  • Table "Posted Package" — primary key "Batch Code" + "Document No." + "Line No."; field Weight (Decimal).
  • Enum "Shipment Doc Status" — values Pending, Posted, Failed.

Requirements

Implement the two codeunits the starter declares.

"Shipment Poster" posts exactly one document. Keep TableNo = "Shipment Document" and do the work in OnRun, where Rec is the document to post:

  1. A document with no packages fails with an error whose text contains has no packages.
  2. A package whose Weight is zero or negative fails the document with an error whose text contains must be positive.
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
  • 16 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