Skip to content

[Event Request] codeunit 99000787 "Create Prod. Order Lines" #30212

Description

@Simon110394

Why do you need this change?

We need an event inside the procedure UpdateProdOrderLine to be able to assign a value to a custom field of the variable ProdOrderLine3 (table "Prod. Order Line"), before UpdateCompPlanningLevel.
The event must fire on each iteration of the repeat..until loop because I need to assign a value to a custom field for each record of the ProdOrderLine3: Record "Prod. Order Line", I'm considering for every iteration of the loop.
Including the new event inside the loop is the only way I can do it.

Describe the request

In procedure UpdateProdOrderLine of codeunit 99000787 "Create Prod. Order Lines" we need an event:

[IntegrationEvent(false, false)]
local procedure OnUpdateProdOrderLineOnBeforeUpdateCompPlanningLevel(var ProdOrderLine3: Record "Prod. Order Line")
begin
end;

Changes between **:

local procedure UpdateProdOrderLine(var ProdOrderLine: Record "Prod. Order Line"; Direction: Option Forward,Backward; LetDueDateDecrease: Boolean)
    var
        ProdOrderLine3: Record "Prod. Order Line";
        ProdOrderComp3: Record "Prod. Order Component";
    begin
        ProdOrderComp3.SetRange(Status, ProdOrderLine.Status);
        ProdOrderComp3.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No.");
        ProdOrderComp3.SetRange("Prod. Order Line No.", ProdOrderLine."Line No.");
        if ProdOrderComp3.FindSet() then
            repeat
                ProdOrderLine3.CopyFilters(ProdOrderLine);
                ProdOrderLine3.SetRange("Item No.", ProdOrderComp3."Item No.");
                ProdOrderLine3.SetRange("Variant Code", ProdOrderComp3."Variant Code");
                if ProdOrderLine3.FindFirst() then begin
                    ProdOrderComp3.CalcFields("Reserved Quantity");
                    TempOldProdOrderComp.Get(ProdOrderComp3.Status, ProdOrderComp3."Prod. Order No.",
                      ProdOrderComp3."Prod. Order Line No.", ProdOrderComp3."Line No.");
                    ProdOrderLine3.Validate(Quantity,
                      ProdOrderLine3.Quantity - TempOldProdOrderComp."Expected Quantity" +
                      ProdOrderComp3."Expected Quantity" - ProdOrderComp3."Reserved Quantity");
                    if ProdOrderLine3."Planning Level Code" < ProdOrderComp3."Planning Level Code" then
                        ProdOrderLine3."Planning Level Code" := ProdOrderComp3."Planning Level Code";
                    AdjustDateAndTime(ProdOrderLine3, ProdOrderComp3."Due Date", ProdOrderComp3."Due Date", ProdOrderComp3."Due Time");
					**OnUpdateProdOrderLineOnBeforeUpdateCompPlanningLevel(ProdOrderLine3)**
                    UpdateCompPlanningLevel(ProdOrderLine3);
                    CalcProdOrder.Recalculate(ProdOrderLine3, Direction::Backward, LetDueDateDecrease);
                    ProdOrderLine3.Modify();
                end;
            until ProdOrderComp3.Next() = 0;
        TempOldProdOrderComp.DeleteAll();

        OnAfterUpdateProdOrderLine(ProdOrderLine, Direction, LetDueDateDecrease);
    end;

Internal work item: AB#640582

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