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]); fieldsStatus(enum"Shipment Doc Status", defaults toPending) and"Error Message"(Text[250]). - Table
"Shipment Package"— primary key"Batch Code"+"Document No."+"Line No."(Integer); fieldWeight(Decimal). - Table
"Posted Package"— primary key"Batch Code"+"Document No."+"Line No."; fieldWeight(Decimal). - Enum
"Shipment Doc Status"— valuesPending,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:
- A document with no packages fails with an error whose text contains
has no packages. - A package whose
Weightis zero or negative fails the document with an error whose text containsmust be positive.
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.
Already on Pro? Sign in