Skip to content

[Event Change Request] Codeunit 5812 "Calculate Standard Cost" - CalcRtngLineCost and CalcRtngLineCostSKU procedures - OnBeforeCalcRtngLineCost() event #30102

@MaricaPiazzalungaActionNet

Description

Why do you need this change?

Dear support, for a customer we need to change at runtime some fields' values of the read Routing Line record in CalcRtngLineCost, before the costs are calculated. For this purpose, we need the access to the Parent Item record in order to recover some information stored in parent item.
Unfortunately the existing event OnBeforeCalcRtngLineCost(RoutingLine, MfgItemQtyBase) does not have ParentItem as parameter and we ask you to add it.

Describe the request

Modify the Integration Event OnBeforeCalcRtngLineCost() adding the parameter var ParentItem, so that extensions can reach the fields of Parent Items record before the calculation of routing line costs.
The same event is called in two procedures: CalcRtngLineCost() and CalcRtngLineCostSKU()

First Location in CalcRtngLineCost() procedure, event OnBeforeCalcRtngLineCost(RoutingLine, MfgItemQtyBase) (at line 1299):

procedure CalcRtngLineCost(RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal; var ParentItem: Record Item)
var
    WorkCenter: Record "Work Center";
    UnitCost: Decimal;
    DirUnitCost: Decimal;
    IndirCostPct: Decimal;
    OvhdRate: Decimal;
    CostTime: Decimal;
    UnitCostCalculation: Enum "Unit Cost Calculation Type";
begin
    -->OnBeforeCalcRtngLineCost(RoutingLine, MfgItemQtyBase);
    if (RoutingLine.Type = RoutingLine.Type::"Work Center") and (RoutingLine."No." <> '') then
        WorkCenter.Get(RoutingLine."No.");

    UnitCost := RoutingLine."Unit Cost per";

    CalcRoutingCostPerUnit(
        RoutingLine.Type, RoutingLine."No.", DirUnitCost, IndirCostPct, OvhdRate, UnitCost, UnitCostCalculation,
        ParentItem, RoutingLine."Standard Task Code");

Second Location in CalcRtngLineCostSKU() procedure, event OnBeforeCalcRtngLineCost(RoutingLine, MfgItemQtyBase) (at line 1341):

internal procedure CalcRtngLineCostSKU(RoutingLine: Record "Routing Line"; MainItem: Record Item; MfgItemQtyBase: Decimal; var SLCap: Decimal; var SLSub: Decimal; var SLCapOvhd: Decimal)
var
    WorkCenter: Record "Work Center";
    UnitCost: Decimal;
    DirUnitCost: Decimal;
    IndirCostPct: Decimal;
    OvhdRate: Decimal;
    CostTime: Decimal;
    UnitCostCalculation: Enum "Unit Cost Calculation Type";
begin
    -->OnBeforeCalcRtngLineCost(RoutingLine, MfgItemQtyBase);
    if (RoutingLine.Type = RoutingLine.Type::"Work Center") and (RoutingLine."No." <> '') then
        WorkCenter.Get(RoutingLine."No.");

    UnitCost := RoutingLine."Unit Cost per";

    CalcRoutingCostPerUnit(RoutingLine.Type, RoutingLine."No.", DirUnitCost, IndirCostPct, OvhdRate, UnitCost, UnitCostCalculation, MainItem, RoutingLine."Standard Task Code");

Current Event Publisher:

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCalcRtngLineCost(var RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal)
    begin
    end;

Change request Event Publisher (added var ParentItem parameter):

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCalcRtngLineCost(var RoutingLine: Record "Routing Line"; MfgItemQtyBase: Decimal; var ParentItem: Record Item)
    begin
    end;

Internal work item: AB#636084

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