microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
791 stars 622 forks source link

[Event Request] Codeunit 5431 "Calc. Item Plan - Plan Wksh.".Code #27650

Open fridrichovsky opened 3 days ago

fridrichovsky commented 3 days ago

Describe the request

Please add new event and parameters `` local procedure "Code"() var PlanningAssignment: Record "Planning Assignment"; PlannedProdOrderLine: Record "Prod. Order Line"; ProdOrder: Record "Production Order"; ReqLineExtern: Record "Requisition Line"; IsHandled: Boolean; begin if not PlanThisItem() then exit;

    ReqLineExtern.SetCurrentKey(Type, "No.", "Variant Code", "Location Code");
    Item.CopyFilter("Variant Filter", ReqLineExtern."Variant Code");
    Item.CopyFilter("Location Filter", ReqLineExtern."Location Code");
    ReqLineExtern.SetRange(Type, ReqLineExtern.Type::Item);
    ReqLineExtern.SetRange("No.", Item."No.");
    //----------------------------------------------------------OnCodeOnAfterSetReqLineFilters:BEGIN
    //OnCodeOnAfterSetReqLineFilters(ReqLineExtern, CurrTemplateName, CurrWorksheetName);
    OnCodeOnAfterSetReqLineFilters(ReqLineExtern, CurrTemplateName, CurrWorksheetName, FromDate, ToDate);
    //----------------------------------------------------------OnCodeOnAfterSetReqLineFilters:END
    if ReqLineExtern.Find('-') then
        repeat
            ReqLineExtern.Delete(true);
        until ReqLineExtern.Next() = 0;

    PlannedProdOrderLine.SetCurrentKey(Status, "Item No.", "Variant Code", "Location Code");
    PlannedProdOrderLine.SetRange(Status, PlannedProdOrderLine.Status::Planned);
    Item.CopyFilter("Variant Filter", PlannedProdOrderLine."Variant Code");
    Item.CopyFilter("Location Filter", PlannedProdOrderLine."Location Code");
    PlannedProdOrderLine.SetRange("Item No.", Item."No.");
    if PlannedProdOrderLine.Find('-') then
        repeat
            if ProdOrder.Get(PlannedProdOrderLine.Status, PlannedProdOrderLine."Prod. Order No.") then begin
                if (ProdOrder."Source Type" = ProdOrder."Source Type"::Item) and
                   (ProdOrder."Source No." = PlannedProdOrderLine."Item No.")
                then
                    ProdOrder.Delete(true);
            end else
                PlannedProdOrderLine.Delete(true);
        until PlannedProdOrderLine.Next() = 0;

    Commit();

    OnCodeOnBeforeInvtProfileOffsettingSetParm(Item);

    CalculateAndGetPlanningCompList();

    Item.CopyFilter(Item."Variant Filter", PlanningAssignment."Variant Code");
    Item.CopyFilter(Item."Location Filter", PlanningAssignment."Location Code");
    PlanningAssignment.SetRange(Inactive, false);
    PlanningAssignment.SetRange("Net Change Planning", true);
    PlanningAssignment.SetRange("Item No.", Item."No.");
    if PlanningAssignment.Find('-') then
        repeat
            if PlanningAssignment."Latest Date" <= ToDate then begin
                PlanningAssignment.Inactive := true;
                PlanningAssignment.Modify();
            end;
        until PlanningAssignment.Next() = 0;

    OnCodeOnAfterGetPlanningComponents(Item);

    Commit();

    TempItemList := Item;

    IsHandled := false;
    OnCodeOnBeforeTempItemListInsert(TempItemList, IsHandled);
    if not IsHandled then
        TempItemList.Insert();
    //-----------------------------------------------------------------OnAfterCode:BEGIN
    //OnAfterCode(TempItemList, FromDate, ToDate);
    //-----------------------------------------------------------------OnAfterCode:END
end;

//---------------------------------------------------------------------------------------OnCodeOnAfterSetReqLineFilters:BEGIN
[IntegrationEvent(false, false)]
//local procedure OnCodeOnAfterSetReqLineFilters(var ReqLineExtern: Record "Requisition Line"; CurrTemplateName: Code[10]; CurrWorksheetName: Code[10])
local procedure OnCodeOnAfterSetReqLineFilters(var ReqLineExtern: Record "Requisition Line"; CurrTemplateName: Code[10]; CurrWorksheetName: Code[10]; var FromDate: Date; var ToDate: Date)
begin
end;
//---------------------------------------------------------------------------------------OnCodeOnAfterSetReqLineFilters:END

//-----------------------------------------------------------------OnAfterCode:BEGIN
[IntegrationEvent(true, false)]
local procedure OnAfterCode(TempItemList: Record Item temporary; var FromDate: Date; var ToDate: Date)
begin
end;
//-----------------------------------------------------------------OnAfterCode:BEGIN 

``

Additional context

We are using FromDate and ToDate variable in our code and we need option for change variables. Internal work item: AB#558150