Skip to content

[W1][Codeunit][22][Item Jnl.-Post Line]` Add var PhysInvtEntryNo and var CapLedgEntryNo to OnBeforePostItemJnlLine in Code #30272

@mavohra

Description

@mavohra

Why do you need this change?

We need to supply externally determined physical inventory entry numbers and capacity ledger entry numbers before an item journal line is posted. When item posting is interleaved with another posting context that also creates physical inventory or capacity entries, the entry numbering must continue from the prior context rather than starting from freshly queried database values.

The standard Code procedure initializes PhysInvtEntryNo from PhysInvtLedgEntry.GetLastEntryNo() in InsertPhysInventoryEntry and CapLedgEntryNo from CapLedgEntry.GetLastEntryNo() in InsertCapLedgEntry. There is no way for a subscriber to supply these entry numbers before the initialization occurs.

The existing OnBeforePostItemJnlLine event passes ItemReg, ItemLedgEntryNo, ValueEntryNo, and ItemApplnEntryNo as var parameters, but does not include PhysInvtEntryNo or CapLedgEntryNo. These two variables are part of the same register state that governs entry numbering and must be transferable together with the other register fields.

Describe the request

Add var PhysInvtEntryNo: Integer and var CapLedgEntryNo: Integer to the existing integration event OnBeforePostItemJnlLine in the Code procedure in Codeunit 22 "Item Jnl.-Post Line". The new parameters follow the existing parameters at the end.

    begin
        OnBeforePostItemJnlLine(ItemJnlLine, CalledFromAdjustment, CalledFromInvtPutawayPick, ItemReg, ItemLedgEntryNo, ValueEntryNo, ItemApplnEntryNo, PhysInvtEntryNo, CapLedgEntryNo); // <---- New parameters at end

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnBeforePostItemJnlLine(var ItemJournalLine: Record "Item Journal Line"; CalledFromAdjustment: Boolean; CalledFromInvtPutawayPick: Boolean; var ItemRegister: Record "Item Register"; var ItemLedgEntryNo: Integer; var ValueEntryNo: Integer; var ItemApplnEntryNo: Integer; var PhysInvtEntryNo: Integer; var CapLedgEntryNo: Integer)
begin
end;

Alternatives evaluated: OnBeforeRunWithCheck fires in RunWithCheck before the Code procedure is called, so the item journal line has not yet been prepared. OnBeforePostLineByEntryType fires inside Code after entry number initialization, too late for injection. No event currently allows overriding PhysInvtEntryNo and CapLedgEntryNo before the entry number initialization blocks.
Internal work item: AB#639005

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an event

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions