Skip to content

[W1][Codeunit][7312][Create Pick] Add integration event OnBeforeGetFromBinContentQty in GetFromBinContentQty #30073

@mavohra

Description

@mavohra

Why do you need this change?

We need to intercept the bin content quantity calculation in GetFromBinContentQty in Codeunit 7312 "Create Pick" before the standard BinContent.Get call, to allow a subscriber to return a custom quantity and skip the standard bin content lookup.

The standard procedure performs a direct BinContent.Get followed by SetTrackingFilterFromWhseItemTrackingLine and CalcFields("Quantity (Base)"). This approach does not account for scenarios where the bin content quantity must be determined by alternative logic, such as when item tracking requires a calculation outside the standard Bin Content table structure.

The existing event OnCreateTempItemTrkgLinesOnBeforeGetFromBinContentQty fires in CreateTempItemTrkgLines immediately before the call to GetFromBinContentQty, but exposes only EntrySummary, ItemNo, VariantCode, and var TotalAvailQtyToPickBase. It does not provide LocCode, FromBinCode, UoMCode, or the WhseItemTrackingLine, and it cannot bypass the BinContent.Get call inside GetFromBinContentQty itself.

Describe the request

Add an integration event OnBeforeGetFromBinContentQty in GetFromBinContentQty in Codeunit 7312 "Create Pick" before BinContent.Get, with IsHandled to allow a subscriber to provide the result and skip the standard bin content lookup.

local procedure GetFromBinContentQty(LocCode: Code[10]; FromBinCode: Code[20]; ItemNo: Code[20]; Variant: Code[20]; UoMCode: Code[10]; WhseItemTrackingLine: Record "Whse. Item Tracking Line"): Decimal
var
    BinContent: Record "Bin Content";
    Result: Decimal;
    IsHandled: Boolean;
begin
    IsHandled := false;
    OnBeforeGetFromBinContentQty(LocCode, FromBinCode, ItemNo, Variant, UoMCode, WhseItemTrackingLine, Result, IsHandled); // <---- New Event
    if not IsHandled then begin
        BinContent.Get(LocCode, FromBinCode, ItemNo, Variant, UoMCode);
        BinContent.SetTrackingFilterFromWhseItemTrackingLine(WhseItemTrackingLine);
        BinContent.CalcFields("Quantity (Base)");
        Result := BinContent."Quantity (Base)";
    end;
    exit(Result);
end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnBeforeGetFromBinContentQty(LocCode: Code[10]; FromBinCode: Code[20]; ItemNo: Code[20]; Variant: Code[20]; UoMCode: Code[10]; var WhseItemTrackingLine: Record "Whse. Item Tracking Line"; var Result: Decimal; var IsHandled: Boolean)
begin
end;

Alternatives evaluated: OnCreateTempItemTrkgLinesOnBeforeGetFromBinContentQty fires in CreateTempItemTrkgLines before GetFromBinContentQty is called, but exposes only EntrySummary, ItemNo, VariantCode, and var TotalAvailQtyToPickBase. It does not expose LocCode, FromBinCode, UoMCode, or the WhseItemTrackingLine, and it cannot bypass the BinContent.Get call inside the procedure. No other event exists at or inside GetFromBinContentQty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions