Skip to content

[main] - Serial and Lot number mismatch when item is produced via Production Order and moved to inventory through an Internal Put-away - #10072

Open
MSNehaNawal wants to merge 1 commit into
mainfrom
bugs/Bug-642316-main-Serial_Lot_Mismatch_InternalPutaway
Open

[main] - Serial and Lot number mismatch when item is produced via Production Order and moved to inventory through an Internal Put-away#10072
MSNehaNawal wants to merge 1 commit into
mainfrom
bugs/Bug-642316-main-Serial_Lot_Mismatch_InternalPutaway

Conversation

@MSNehaNawal

@MSNehaNawal MSNehaNawal commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Bug 642316: [ALL-E] Serial and Lot number mismatch when item is produced via Production Order and moved to inventory through an Internal Put-away

Fixes AB#642316

Issue - Serial and Lot number mismatch when item is produced via Production Order and moved to inventory through an Internal Put-away

Cause - The put-away validation was skipped as time of registration.As a result, the lot requirement was never enforced at registration time and a blank lot slipped through.

Solution - Added a data-driven check in WhseActivityRegister.CheckLines → CheckItemTrackingRequiredForPutAway that compares the put-away line against the actual posted Item Ledger Entry instead of the configuration flags. For each Put-away line carrying a Serial No., it resolves the open Item Ledger Entry by Item / Variant / Location / Serial No.; if that entry has a Lot No., the line's Lot No. must match it:

@github-actions github-actions Bot added the SCM GitHub request for SCM area label Aug 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 10, 2026
@MSNehaNawal
MSNehaNawal marked this pull request as ready for review August 10, 2026 11:40
@MSNehaNawal
MSNehaNawal requested a review from a team August 10, 2026 11:40
Cust.CheckBlockedCustOnDocs(Cust, GlobalWhseActivHeader."Source Document", false, false);
end;

local procedure CheckItemTrackingRequiredForPutAway(WhseActivLine: Record "Warehouse Activity Line")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Breaking\ Changes}$

This change introduces a new runtime contract in published codeunit 7307 "Whse.-Activity-Register": registering a Put-away for a serial+lot tracked item now fails with a TestField error when the line's Lot No. is blank while the matching Item Ledger Entry carries a Lot No., where the same flow previously completed successfully (the new test RegisterPutAwayWithBlankLotForSerialAndLotItemIsBlocked demonstrates exactly this). No public AL signature changed, but existing extensions, integrations, or already-open Put-away activity lines created before this change carry no compatibility or migration path — on upgrade they will start failing registration with no accompanying data fix-up. Treat this as a breaking behavioral change: provide a migration/backfill for existing open lines, an opt-in/feature-flag gate, or at minimum a clear release-note callout, and document the new OnBeforeCheckItemTrackingRequiredForPutAway event as the supported way for subscribers to preserve legacy behavior if needed.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4

if Location."Bin Mandatory" then
CheckBinRelatedFields(GlobalWhseActivLine);

CheckItemTrackingRequiredForPutAway(GlobalWhseActivLine);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

RegisterActivityLines now calls the new CheckItemTrackingRequiredForPutAway inside the warehouse-line repeat/until loop, and that helper performs a persistent Item Ledger Entry lookup (FindLast) for every qualifying Put-away line. This is an N+1 database-access pattern on a hot registration path; SetLoadFields reduces the payload per row but does not remove the per-line lookup. Consider preloading/caching the required Item Ledger Entry data by item/variant/location/serial key once before iterating the activity lines, rather than issuing one lookup per line.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4

if WhseActivLine."Serial No." = '' then
exit;

ItemLedgerEntry.SetCurrentKey("Item No.", "Variant Code", "Location Code", "Serial No.");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Performance}$

The new Item Ledger Entry lookup uses SetCurrentKey("Item No.", "Variant Code", "Location Code", "Serial No."), but the W1 Item Ledger Entry table defines no key with that leading field order (verified in ItemLedgerEntry.Table.al: the closest candidates are Key20 = "Serial No.", "Item No.", Open, "Variant Code", Positive, "Location Code", "Posting Date" and Key17 = "Item No.", Open, "Variant Code", Positive, "Lot No.", "Serial No.", "Package No."). Because the selected key does not align with the actual filters (Item No., Variant Code, Location Code, Serial No., Open) applied before FindLast, the engine falls back to a less selective scan, and — since ordering is not guaranteed to match intent — if more than one open entry ever satisfies the same Item/Variant/Location/Serial combination, FindLast can pick an entry other than the one the caller intends, comparing the Put-away line's Lot No. against the wrong ledger entry. Use an existing key that actually leads with the applied filters (for example Key20, which starts with Serial No./Item No./Open) so the lookup is both efficient and deterministic.

Knowledge:

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4

[Test]
[HandlerFunctions('ItemTrackingPageHandler,EnterQuantityToCreatePageHandler')]
[Scope('OnPrem')]
procedure RegisterPutAwayWithBlankLotForSerialAndLotItemIsBlocked()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

The new test RegisterPutAwayWithBlankLotForSerialAndLotItemIsBlocked verifies only the failure path after clearing the Lot No. It does not add a companion success-path case that keeps the matching Lot No. and proves RegisterWarehouseActivity still succeeds, so an implementation that blocked every serial-and-lot Put-away (not just mismatched ones) would still satisfy this coverage. Add a positive-path test (or extend this one) that registers the Put-away with the unchanged, matching Lot No. and asserts success.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SCM GitHub request for SCM area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant