Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 99000813 "Carry Out Action".InsertProdOrderLine #27670

Open
fridrichovsky opened this issue Nov 22, 2024 · 1 comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@fridrichovsky
Copy link
Contributor

fridrichovsky commented Nov 22, 2024

Describe the request

Please add new event

    procedure InsertProdOrderLine(RequisitionLine: Record "Requisition Line"; ProductionOrder: Record "Production Order"; Item: Record Item)
    var
        ProdOrderLine: Record "Prod. Order Line";
        NextLineNo: Integer;
    begin
        ProdOrderLine.SetRange("Prod. Order No.", ProductionOrder."No.");
        ProdOrderLine.SetRange(Status, ProductionOrder.Status);
        ProdOrderLine.LockTable();
        if ProdOrderLine.FindLast() then
            NextLineNo := ProdOrderLine."Line No." + 10000
        else
            NextLineNo := 10000;

        OnInsertProdOrderLineOnBeforeProdOrderLineInit(RequisitionLine, Item);
        ProdOrderLine.Init();
        ProdOrderLine.BlockDynamicTracking(true);
        ProdOrderLine.Status := ProductionOrder.Status;
        ProdOrderLine."Prod. Order No." := ProductionOrder."No.";
        ProdOrderLine."Line No." := NextLineNo;
        ProdOrderLine."Item No." := RequisitionLine."No.";
        ProdOrderLine.Validate("Unit of Measure Code", RequisitionLine."Unit of Measure Code");
        ProdOrderLine."Production BOM Version Code" := RequisitionLine."Production BOM Version Code";
        ProdOrderLine."Routing Version Code" := RequisitionLine."Routing Version Code";
        ProdOrderLine."Routing Type" := RequisitionLine."Routing Type";
        ProdOrderLine."Routing Reference No." := ProdOrderLine."Line No.";
        ProdOrderLine.Description := RequisitionLine.Description;
        ProdOrderLine."Description 2" := RequisitionLine."Description 2";
        ProdOrderLine."Variant Code" := RequisitionLine."Variant Code";
        ProdOrderLine."Location Code" := RequisitionLine."Location Code";
        OnInsertProdOrderLineOnBeforeGetBinCode(ProdOrderLine, RequisitionLine);
        if RequisitionLine."Bin Code" <> '' then
            ProdOrderLine.Validate("Bin Code", RequisitionLine."Bin Code")
        else
            CalculateProdOrder.SetProdOrderLineBinCodeFromRoute(ProdOrderLine, ProductionOrder."Location Code", ProductionOrder."Routing No.");
        ProdOrderLine."Scrap %" := RequisitionLine."Scrap %";
        ProdOrderLine."Production BOM No." := RequisitionLine."Production BOM No.";
        ProdOrderLine."Inventory Posting Group" := Item."Inventory Posting Group";
        OnInsertProdOrderLineOnBeforeValidateUnitCost(RequisitionLine, ProductionOrder, ProdOrderLine, Item);
        ProdOrderLine.Validate("Unit Cost", RequisitionLine."Unit Cost");
        ProdOrderLine."Routing No." := RequisitionLine."Routing No.";
        ProdOrderLine."Starting Time" := RequisitionLine."Starting Time";
        ProdOrderLine."Starting Date" := RequisitionLine."Starting Date";
        ProdOrderLine."Ending Time" := RequisitionLine."Ending Time";
        ProdOrderLine."Ending Date" := RequisitionLine."Ending Date";
        ProdOrderLine."Due Date" := RequisitionLine."Due Date";
        ProdOrderLine.Status := ProductionOrder.Status;
        ProdOrderLine."Planning Level Code" := RequisitionLine."Planning Level";
        ProdOrderLine."Indirect Cost %" := RequisitionLine."Indirect Cost %";
        ProdOrderLine."Overhead Rate" := RequisitionLine."Overhead Rate";
        UpdateProdOrderLineQuantity(ProdOrderLine, RequisitionLine, Item);
        if not (ProductionOrder.Status = ProductionOrder.Status::Planned) then
            ProdOrderLine."Planning Flexibility" := RequisitionLine."Planning Flexibility";
        ProdOrderLine.UpdateDatetime();
        ProdOrderLine."Shortcut Dimension 1 Code" := RequisitionLine."Shortcut Dimension 1 Code";
        ProdOrderLine."Shortcut Dimension 2 Code" := RequisitionLine."Shortcut Dimension 2 Code";
        ProdOrderLine."Dimension Set ID" := RequisitionLine."Dimension Set ID";
        OnInsertProdOrderLineWithReqLine(ProdOrderLine, RequisitionLine);
        ProdOrderLine.Insert();
        OnInsertProdOrderLineOnAfterProdOrderLineInsert(ProdOrderLine, RequisitionLine);
        CalculateProdOrder.CalculateProdOrderDates(ProdOrderLine, false);

        ReqLineReserve.TransferPlanningLineToPOLine(RequisitionLine, ProdOrderLine, RequisitionLine."Net Quantity (Base)", false);
        if RequisitionLine.Reserve and not (ProdOrderLine.Status = ProdOrderLine.Status::Planned) then
            ReserveBindingOrderToProd(ProdOrderLine, RequisitionLine);

        //----------------------------------------OnInsertProdOrderLineOnBeforeModifyProdOrderLine:BEGIN
        OnInsertProdOrderLineOnBeforeModifyProdOrderLine(ProdOrderLine, RequisitionLine);
        //----------------------------------------OnInsertProdOrderLineOnBeforeModifyProdOrderLine:END
        ProdOrderLine.Modify();
        SetProdOrderLineBinCodeFromPlanningRtngLines(ProductionOrder, ProdOrderLine, RequisitionLine, Item);
        TransferBOM(RequisitionLine, ProductionOrder, ProdOrderLine."Line No.");
        TransferCapNeed(RequisitionLine, ProductionOrder, ProdOrderLine."Routing No.", ProdOrderLine."Routing Reference No.");

        if ProdOrderLine."Planning Level Code" > 0 then
            UpdateComponentLink(ProdOrderLine);

        OnAfterInsertProdOrderLine(RequisitionLine, ProductionOrder, ProdOrderLine, Item);

        FinalizeOrderHeader(ProductionOrder);
    end;

    //----------------------------------------OnInsertProdOrderLineOnBeforeModifyProdOrderLine:BEGIN
    [IntegrationEvent(true, false)]
     local procedure OnInsertProdOrderLineOnBeforeModifyProdOrderLine(var ProdOrderLine: Record "Prod. Order Line"; var RequisitionLine: Record "Requisition Line")
     begin
     end;
    //----------------------------------------OnInsertProdOrderLineOnBeforeModifyProdOrderLine:END

Additional context

We need change values in table
Internal work item: AB#558493

@BardurKnudsen BardurKnudsen added event-request Request for adding an event SCM GitHub request for SCM area labels Nov 25, 2024
@BardurKnudsen
Copy link

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area
Projects
None yet
Development

No branches or pull requests

2 participants