Bug 634238: [Subcontracting] Subcontracting false 'already created' warning when prod order has multiple lines sharing routing/operation#8121
Conversation
…s sharing routing/operation (#634238) When a Released Production Order had multiple Prod. Order lines using the same Routing/Operation but different Routing Reference No., creating a Subcontracting Order from the routing of a second line incorrectly raised the 'Purchase order(s) have already been created' warning and, when confirmed, opened the unrelated PO of the first line. Root cause: the existence check in ShowExistingPurchaseOrdersForRoutingLines and the navigation in ShowCreatedPurchaseOrder filtered Purchase Lines by Prod. Order No. + Routing No. + Operation No. but not by Routing Reference No., which is the field that identifies the specific Prod. Order line. Fix: add Routing Reference No. to the existence-check filter, and propagate the current routing line's Routing Reference No. to the single-PO navigation branch via a new RoutingReferenceNo global (mirroring the existing OperationNo pattern). Test: SubcSubcontractingTest.CreateSubcontractingPOForEachProdOrderLineWhenLinesShareRoutingAndOperation
There was a problem hiding this comment.
AL Documentation Audit
Documentation gaps were detected in the following apps:
- Subcontracting-Test: 9% documentation coverage
- Subcontracting: 0% documentation coverage
To generate documentation, run /al-docs init or /al-docs update using GitHub Copilot CLI or Claude Code.
This review is for awareness to help keep documentation in sync with code changes. It is okay to dismiss this request.
Shared handler now enqueues data for 20+ unaware tests
Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…tractingTest.Codeunit.al Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…tractingTest.Codeunit.al Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Shared Initialize modified; may break existing tests
Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…tractingTest.Codeunit.al Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
RoutingReferenceNo not cleared in internal cleanupThe existing cleanup code at line 213 clears OperationNo but does not clear the newly added RoutingReferenceNo. If this procedure is called independently (e.g. in a path that doesn't go through the page extension's explicit Clear+Set calls), RoutingReferenceNo will retain its previous value and incorrectly filter the purchase line lookup. Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Chethan Thopaiah <41570277+ChethanT@users.noreply.github.com>
- SubcProdOrderRtng.PageExt.al: add "Routing Reference No." filter to the NoOfCreatedPurchOrder = 0 existence-check branch — same root cause as the codeunit fix; without it the "No subcontracting order was created" message could be wrongly suppressed when a sibling Prod. Order line already has an unrelated PO. - SubcSubcontractingTest.Codeunit.al: revert garbled bot suggestions in CreateSubcontractingPOForEachProdOrderLineWhenLinesShareRoutingAndOperation (broken indentation, duplicated WHEN block with a placeholder comment in place of filters) and add a second test CreateSubcontractingPONavigatesToOwnPOWhenLinesShareRoutingAndOperation that confirms "view them" and asserts the opened PO is the one tied to the invoked routing line's Routing Reference No. — exercising the single-PO navigation branch that consumes the new RoutingReferenceNo global. Drops the now-redundant UpdateSubMgmtSetupWithReqWkshTemplate call (already in Initialize). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
…Subcontracting/634238-WrongMessagePOWith2Lines
ClearOperationNo doesn't reset RoutingReferenceNoThe existing Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
…Subcontracting/634238-WrongMessagePOWith2Lines
RoutingReferenceNo not cleared after ShowCreatedPurchaseOrderThe existing Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
Paired Clear/Set API is fragile; consider a single setterExposing Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
UpdateSubMgmtSetupWithReqWkshTemplate runs on every test
Recommendation:
Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why |
AnalysisScenario Validity:
Correctness:
Side Effects:
Risk Assessment:
Test Coverage:
Recommendation: Accept
|
Bug
AB#634238 — When a Released Production Order has multiple Prod. Order lines that share the same Routing/Operation but differ by
Routing Reference No., creating a Subcontracting Order from the routing of a second line:Root cause
Three filter sites identified Prod. Order lines by
Prod. Order No.+Routing No.+Operation No.only, missingRouting Reference No.— the field that disambiguates Prod. Order lines sharing the same routing/operation:Subc. Purchase Order Creator(codeunit99001557)ShowExistingPurchaseOrdersForRoutingLines— drives the "already created" prompt.ShowCreatedPurchaseOrder(single-PO navigation branch) — drives which PO opens.SubcProdOrderRtng.PageExt.al— the Create Subcontracting Order action'sif NoOfCreatedPurchOrder = 0fallback that decides whether to show the "No subcontracting order was created" message.The static
RunPageLinkon the Subcontracting Purchase Order Lines action inSubcProdOrderRtng.PageExt.alalready includesRouting Reference No.as a filter — confirming this is the canonical filter pattern the programmatic checks should follow.Fix
SubcPurchaseOrderCreator.Codeunit.alShowExistingPurchaseOrdersForRoutingLines: addPurchaseLine.SetRange("Routing Reference No.", ProdOrderRoutingLine."Routing Reference No.")to the existence check.ShowCreatedPurchaseOrder: add aRoutingReferenceNoglobal withSet/Clearaccessors (mirroring the existingOperationNopattern) and apply it in the single-PO navigation branch.SubcProdOrderRtng.PageExt.alClearRoutingReferenceNoForCreatedPurchaseOrder()+SetRoutingReferenceNoForCreatedPurchaseOrder(Rec."Routing Reference No.")before invokingShowCreatedPurchaseOrder.if NoOfCreatedPurchOrder = 0fallback also filters by"Routing Reference No." = Rec."Routing Reference No.", so the "No subcontracting order was created" message is no longer wrongly suppressed when a sibling Prod. Order line already has an unrelated PO.The change is minimal and targeted — no broader refactoring.
Tests
Two tests added to codeunit
139989 "Subc. Subcontracting Test". Both build a single Released Production Order with two Prod. Order lines for the same item on different locations (so they share routing/operation but have differentRouting Reference No.) and invoke Create Subcontracting Order on each line's routing entry.CreateSubcontractingPOForEachProdOrderLineWhenLinesShareRoutingAndOperation— covers Symptom 1. Captures the confirm-handler question text and asserts each invocation ends with the "1 Purchase Order(s) created" confirmation — i.e. neither raises the false "already created" warning.CreateSubcontractingPONavigatesToOwnPOWhenLinesShareRoutingAndOperation— covers Symptom 2. Confirms "view them" withYesand captures the opened Purchase Order'sNo.via a page handler, then asserts the opened PO contains aPurchase Linecarrying the invoked routing line'sRouting Reference No.— proving the single-PO navigation branch routes to the correct PO.Both tests fail on the unfixed code and pass after the fix.
The test app gains a dependency on
Library - Variable Storageso the confirm/page handlers can enqueue captured values for assertion.Work item
AB#634238