Question 520
At fictional Juniper Hospitality, the Business Central development team is supporting property purchasing and billing and reviewing AL business logic and user experience during a source-control pull request (MB820-4.3-160). The observed development issue is that a batch routine must process each line once but uses an unbounded loop that never advances the record pointer. Which Business Central or AL development principle best explains the right response?
Explanation
Correct Answer
The governing principle is that loop termination and record iteration are core control-flow requirements. The engineering response is to use a correct AL iteration pattern with repeat/until and Next() or suitable FindSet traversal. Verification should show that the process terminates after exactly the targeted rows. Applied here, the relevant facts are: The observed development issue is that a batch routine must process each line once but uses an unbounded loop that never advances the record pointer. The question asks which Business Central or AL development principle best explains the right response.
Incorrect Answers
“Data types should represent semantics, not just printable appearance” concerns the alternative task “use a suitable Decimal variable and numeric expressions, formatting only at display boundaries”, but the stated failure is that a batch routine must process each line once but uses an unbounded loop that never advances the record pointer. The required measure is to use a correct AL iteration pattern with repeat/until and Next() or suitable FindSet traversal.
“Shared business records need concurrency-aware mutation logic” supports the separate task “use a controlled concurrency/locking strategy and validate expected record state before updating”, not the reported problem: a batch routine must process each line once but uses an unbounded loop that never advances the record pointer. This case instead calls for “use a correct AL iteration pattern with repeat/until and Next() or suitable FindSet traversal”.
“Record API success conditions must be handled explicitly” concerns the separate step “check the Boolean result of the record lookup and handle not-found cases deliberately”. The reported issue is that a batch routine must process each line once but uses an unbounded loop that never advances the record pointer, so the direct response is to use a correct AL iteration pattern with repeat/until and Next() or suitable FindSet traversal.