Why do you need this change?
Event Request: OnPostConsumptionOnBeforeInsertRemainingConsumpEntry
Please add a new integration event with an IsHandled parameter in the PostConsumption procedure of codeunit 99000822 "Mfg. Item Jnl.-Post Line", immediately before the InsertConsumpEntry call that handles the remaining quantity to post.
The existing event OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntry fires at the correct location but has no IsHandled parameter, so there is no way to suppress the InsertConsumpEntry call that follows it.
In some manufacturing scenarios, the remaining consumption entry must be skipped. For example, when ItemJnlLine."Value Entry Type" is Revaluation, posting a standard consumption entry is incorrect - the line represents a cost correction, not a physical movement, and the InsertConsumpEntry call should not run.
While InsertConsumpEntry does contain an internal check for the Revaluation value entry type at the warehouse journal step, this only prevents the warehouse journal line from being created. It does not prevent sender.PostItem(ItemJnlLine) from running, which is called unconditionally at the end of InsertConsumpEntry for all value entry types. For a revaluation line, this would post an incorrect item ledger entry - a physical consumption movement - on top of what is intended to be a cost-only adjustment. Additionally, before reaching the warehouse check, InsertConsumpEntry already overwrites ItemJnlLine.Quantity, ItemJnlLine."Quantity (Base)", and related fields with the remaining quantity. These modifications on a revaluation line are also incorrect. The entire call must be skipped, not just the warehouse part inside it.
Alternatives Evaluated
The following existing events were evaluated:
-
OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntry(ItemJnlLine, ProdOrderComp): Fires at the correct location but has no IsHandled parameter. Adding IsHandled to an existing event is not allowed as you mentioned in - Previous Event Request. This event cannot be used.
-
OnBeforeInsertConsumpEntry(ProdOrderComp, QtyBase, ModifyProdOrderComp, ItemJnlLine, TempSplitItemJnlLine): Fires at the start of the InsertConsumpEntry local procedure. It has no IsHandled parameter so it cannot skip the procedure's logic. More importantly, it fires after the call to InsertConsumpEntry has already begun - at that point ItemJnlLine.Quantity, ItemJnlLine."Quantity (Base)", and related fields are about to be overwritten. There is no way to prevent these modifications from inside this event. This event cannot be used.
None of the existing events allow a subscriber to suppress the InsertConsumpEntry call for the remaining quantity before any of its side effects occur.
Performance Considerations
The event fires once per execution of the remaining-quantity block inside PostConsumption. The proposal adds one Boolean variable and one conditional check. No measurable performance impact is expected.
Data Sensitivity Review
The event exposes:
var ItemJnlLine: Record "Item Journal Line" - the journal line being posted; already in scope and already used by the existing event at the same location.
var ProdOrderComp: Record "Prod. Order Component" - the production order component; already in scope and already used by the existing event at the same location.
var IsHandled: Boolean - standard skip flag.
No sensitive data is introduced beyond what the existing event at this location already exposes.
Multi-Extension Interaction
The standard IsHandled pattern applies. All subscribers run in sequence. If a subscriber sets IsHandled := true, the InsertConsumpEntry call is skipped, but subsequent subscribers still run unless they check if IsHandled then exit. When no subscriber is active, behaviour is unchanged.
Describe the request
Current code in PostConsumption:
OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntry(ItemJnlLine, ProdOrderComp);
if RemQtyToPost <> 0 then
InsertConsumpEntry(
ItemJnlLine, ProdOrderComp, ItemJnlLine."Prod. Order Comp. Line No.",
RemQtyToPost, false, ItemLedgEntryNo, TempSplitItemJnlLine, sender);
Requested change:
OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntry(ItemJnlLine, ProdOrderComp);
//>> code change start
IsHandled := false;
OnPostConsumptionOnBeforeInsertRemainingConsumpEntry(ItemJnlLine, ProdOrderComp, IsHandled);
//<< code change end
if not IsHandled then
if RemQtyToPost <> 0 then
InsertConsumpEntry(
ItemJnlLine, ProdOrderComp, ItemJnlLine."Prod. Order Comp. Line No.",
RemQtyToPost, false, ItemLedgEntryNo, TempSplitItemJnlLine, sender);
New event declaration:
[IntegrationEvent(false, false)]
local procedure OnPostConsumptionOnBeforeInsertRemainingConsumpEntry(var ItemJnlLine: Record "Item Journal Line"; var ProdOrderComp: Record "Prod. Order Component"; var IsHandled: Boolean)
begin
end;
Subscriber example (for illustration only):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Mfg. Item Jnl.-Post Line", 'OnPostConsumptionOnBeforeInsertRemainingConsumpEntry', '', false, false)]
local procedure OnBeforeInsertRemainingConsumpEntryHandler(var ItemJnlLine: Record "Item Journal Line"; var ProdOrderComp: Record "Prod. Order Component"; var IsHandled: Boolean)
begin
// Skip the remaining consumption entry for revaluation lines -
// these represent cost corrections and must not produce a physical movement entry.
if ItemJnlLine."Value Entry Type" = ItemJnlLine."Value Entry Type"::Revaluation then
IsHandled := true;
end;
Internal work item: AB#640856
Why do you need this change?
Event Request:
OnPostConsumptionOnBeforeInsertRemainingConsumpEntryPlease add a new integration event with an
IsHandledparameter in thePostConsumptionprocedure of codeunit 99000822 "Mfg. Item Jnl.-Post Line", immediately before theInsertConsumpEntrycall that handles the remaining quantity to post.The existing event
OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntryfires at the correct location but has noIsHandledparameter, so there is no way to suppress theInsertConsumpEntrycall that follows it.In some manufacturing scenarios, the remaining consumption entry must be skipped. For example, when
ItemJnlLine."Value Entry Type"isRevaluation, posting a standard consumption entry is incorrect - the line represents a cost correction, not a physical movement, and theInsertConsumpEntrycall should not run.While
InsertConsumpEntrydoes contain an internal check for theRevaluationvalue entry type at the warehouse journal step, this only prevents the warehouse journal line from being created. It does not preventsender.PostItem(ItemJnlLine)from running, which is called unconditionally at the end ofInsertConsumpEntryfor all value entry types. For a revaluation line, this would post an incorrect item ledger entry - a physical consumption movement - on top of what is intended to be a cost-only adjustment. Additionally, before reaching the warehouse check,InsertConsumpEntryalready overwritesItemJnlLine.Quantity,ItemJnlLine."Quantity (Base)", and related fields with the remaining quantity. These modifications on a revaluation line are also incorrect. The entire call must be skipped, not just the warehouse part inside it.Alternatives Evaluated
The following existing events were evaluated:
OnPostConsumptionOnRemQtyToPostOnBeforeInsertConsumpEntry(ItemJnlLine, ProdOrderComp): Fires at the correct location but has noIsHandledparameter. AddingIsHandledto an existing event is not allowed as you mentioned in - Previous Event Request. This event cannot be used.OnBeforeInsertConsumpEntry(ProdOrderComp, QtyBase, ModifyProdOrderComp, ItemJnlLine, TempSplitItemJnlLine): Fires at the start of theInsertConsumpEntrylocal procedure. It has noIsHandledparameter so it cannot skip the procedure's logic. More importantly, it fires after the call toInsertConsumpEntryhas already begun - at that pointItemJnlLine.Quantity,ItemJnlLine."Quantity (Base)", and related fields are about to be overwritten. There is no way to prevent these modifications from inside this event. This event cannot be used.None of the existing events allow a subscriber to suppress the
InsertConsumpEntrycall for the remaining quantity before any of its side effects occur.Performance Considerations
The event fires once per execution of the remaining-quantity block inside
PostConsumption. The proposal adds one Boolean variable and one conditional check. No measurable performance impact is expected.Data Sensitivity Review
The event exposes:
var ItemJnlLine: Record "Item Journal Line"- the journal line being posted; already in scope and already used by the existing event at the same location.var ProdOrderComp: Record "Prod. Order Component"- the production order component; already in scope and already used by the existing event at the same location.var IsHandled: Boolean- standard skip flag.No sensitive data is introduced beyond what the existing event at this location already exposes.
Multi-Extension Interaction
The standard
IsHandledpattern applies. All subscribers run in sequence. If a subscriber setsIsHandled := true, theInsertConsumpEntrycall is skipped, but subsequent subscribers still run unless they checkif IsHandled then exit. When no subscriber is active, behaviour is unchanged.Describe the request
Current code in
PostConsumption:Requested change:
New event declaration:
Subscriber example (for illustration only):
Internal work item: AB#640856