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 5870 "Calculate BOM Tree" - Procedure GenerateProdOrderLineSubTree - OnBeforeGenerateProdOrderLineSubTree #28025

Open
mavohra opened this issue Jan 30, 2025 · 0 comments

Comments

@mavohra
Copy link

mavohra commented Jan 30, 2025

Describe the request

Please add an event OnBeforeGenerateProdOrderLineSubTree in the procedure GenerateProdOrderLineSubTree in Codeunit 5870 "Calculate BOM Tree"

 local procedure GenerateProdOrderLineSubTree(ProdOrderLine: Record "Prod. Order Line"; var BOMBuffer: Record "BOM Buffer"): Boolean
    var
        OldProdOrderLine: Record "Prod. Order Line";
        ProdOrderComp: Record "Prod. Order Component";
        ParentBOMBuffer: Record "BOM Buffer";
        IsHandled: Boolean;
    begin
        
        OnBeforeGenerateProdOrderLineSubTree(ProdOrderLine, BOMBuffer, ParentBOMBuffer, IsHandled); // <--- New Event
        if IsHandled then
            exit;

        ParentBOMBuffer := BOMBuffer;
        ProdOrderComp.SetRange(Status, ProdOrderLine.Status);
        ProdOrderComp.SetRange("Prod. Order No.", ProdOrderLine."Prod. Order No.");
        ProdOrderComp.SetRange("Prod. Order Line No.", ProdOrderLine."Line No."); // <----- We need to use a setfilter here instead of setrange
        if ProdOrderComp.FindSet() then begin
            repeat
                if ProdOrderComp."Item No." <> '' then begin
                    OldProdOrderLine.Get(ProdOrderComp.Status, ProdOrderComp."Prod. Order No.", ProdOrderComp."Prod. Order Line No.");  // <-----we need to send `ProdOrderLine."Line No."` instead of  ProdOrderComp."Prod. Order Line No."
                    if ProdOrderLine."Due Date" <> OldProdOrderLine."Due Date" then
                        ProdOrderComp."Due Date" := ProdOrderComp."Due Date" - (OldProdOrderLine."Due Date" - ProdOrderLine."Due Date");

                    BOMBuffer.SetLocationVariantFiltersFrom(ItemFilter);
                    BOMBuffer.TransferFromProdOrderComp(EntryNo, ProdOrderComp);
                    GenerateItemSubTree(ProdOrderComp."Item No.", BOMBuffer);
                end;
            until ProdOrderComp.Next() = 0;
            BOMBuffer := ParentBOMBuffer;

            exit(true);
        end;
    end;
[IntegrationEvent(false, false)]
    local procedure OnBeforeGenerateProdOrderLineSubTree(ProdOrderLine: Record "Prod. Order Line"; var BOMBuffer: Record "BOM Buffer"; var ParentBOMBuffer: Record "BOM Buffer"; var IsHandled: Boolean)
    begin
    end;

Additional context

We would like to have an event with isHandled parameter to override the code with our custom code.

We need to change the ProdOrderComp.SetRange("Prod. Order Line No.", ProdOrderLine."Line No."); to use ProdOrderComp.SetFilter("Prod. Order Line No.", '%1|0', ProdOrderLine."Line No.") on line No. 466

additionally, we need to send ProdOrderLine."Line No." instead of ProdOrderComp."Prod. Order Line No." in the OldProdOrderLine.Get on Line No. 470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant