Skip to content

[Event Request] Report 99000754 "Rolled-up Cost Shares".BOMLoop.OnAfterGetRecord #29206

Description

@fridrichovsky

Why do you need this change?

We are using own logic for CompItem.Get so we need option change record CompItem.

Describe the request

Please add new event

trigger OnAfterGetRecord()
    begin
        while ProdBOMLine[Index].Next() = 0 do begin
            if NoListType[Index] = NoListType[Index] ::Item then
                Level := Level - 1;
            Index := Index - 1;
            if Index < 1 then
                CurrReport.Break();
            if NoListType[Index] = NoListType[Index] ::Item then
                MfgItem.Get(NoList[Index])
            else
                MfgItem."Production BOM No." := NoList[Index];
            ProdBOMLine[Index].SetRange("Production BOM No.", MfgItem."Production BOM No.");
            ProdBOMLine[Index].SetRange("Version Code", VersionCode[Index]);
        end;

        NextIndex := Index;

        OnOnAfterGetRecordOnBOMLoopOnBeforeCalcCompItemQtyBase(Item, ProdBOMLine[Index], CalculateDate);

        CompItemQtyBase :=
          MfgCostCalcMgt.CalcCompItemQtyBase(
            ProdBOMLine[Index], CalculateDate, MfgItemQtyBase[Index], MfgItem."Routing No.",
            NoListType[Index] = NoListType[Index] ::Item);

        Clear(CompItem);

        case ProdBOMLine[Index].Type of
            ProdBOMLine[Index].Type::Item:
                begin
                    CompItem.Get(ProdBOMLine[Index]."No.");
                    //----------------------------------------------------------------OnAfterGetRecordBOMLoopOnAfterGetCompItem:BEGIN
                    OnAfterGetRecordBOMLoopOnAfterGetCompItem(MfgItem, ProductionBOMLine, CompItem, Index);
                    //----------------------------------------------------------------OnAfterGetRecordBOMLoopOnAfterGetCompItem:END
                    if CompItem.IsMfgItem() and (CompItem."Production BOM No." <> '') then begin
                        ProdBOMHeader.Get(CompItem."Production BOM No.");
                        if ProdBOMHeader.Status = ProdBOMHeader.Status::Closed then
                            CurrReport.Skip();
                        NextIndex := Index + 1;
                        if Index > 1 then
                            if (NextIndex > 50) or (ProdBOMLine[Index]."No." = NoList[Index - 1]) then
                                Error(ProductionBomErr, 50, Item."No.", MfgItem."Production BOM No.", Level);
                        VersionCode[NextIndex] := VersionMgt.GetBOMVersion(CompItem."Production BOM No.", CalculateDate, true);
                        NoListType[NextIndex] := NoListType[NextIndex] ::Item;
                        NoList[NextIndex] := CompItem."No.";

                        Clear(ProdBOMLine[NextIndex]);
                        ProdBOMLine[NextIndex].SetRange("Production BOM No.", CompItem."Production BOM No.");
                        ProdBOMLine[NextIndex].SetRange("Version Code", VersionCode[NextIndex]);
                        ProdBOMLine[NextIndex].SetFilter("Starting Date", '%1|..%2', 0D, CalculateDate);
                        ProdBOMLine[NextIndex].SetFilter("Ending Date", '%1|%2..', 0D, CalculateDate);

                        LotSize[NextIndex] := GetLotSize(CompItem);
                        MfgItemQtyBase[NextIndex] := CalcMfgItemQtyBase(CompItem, VersionCode[NextIndex], LotSize[NextIndex]);
                        Quantity[NextIndex] := Quantity[Index] * CompItemQtyBase / LotSize[Index];
                    end;
                end;
            ProdBOMLine[Index].Type::"Production BOM":
                begin
                    NextIndex := Index + 1;

                    ProdBOMHeader.Get(ProdBOMLine[Index]."No.");
                    if ProdBOMHeader.Status = ProdBOMHeader.Status::Closed then
                        CurrReport.Skip();
                    if Index > 1 then
                        if (NextIndex > 50) or (ProdBOMLine[Index]."No." = NoList[Index - 1]) then
                            Error(ProductionBomErr, 50, Item."No.", MfgItem."Production BOM No.", Level);
                    VersionCode[NextIndex] := VersionMgt.GetBOMVersion(ProdBOMHeader."No.", CalculateDate, true);
                    NoListType[NextIndex] := NoListType[NextIndex] ::"Production BOM";
                    NoList[NextIndex] := ProdBOMHeader."No.";

                    Clear(ProdBOMLine[NextIndex]);
                    ProdBOMLine[NextIndex].SetRange("Production BOM No.", NoList[NextIndex]);
                    ProdBOMLine[NextIndex].SetRange("Version Code", VersionCode[NextIndex]);
                    ProdBOMLine[NextIndex].SetFilter("Starting Date", '%1|..%2', 0D, CalculateDate);
                    ProdBOMLine[NextIndex].SetFilter("Ending Date", '%1|%2..', 0D, CalculateDate);

                    LotSize[NextIndex] := LotSize[Index];
                    MfgItemQtyBase[NextIndex] := CompItemQtyBase;
                    Quantity[NextIndex] := Quantity[Index];
                end;
        end;
    end;

    //----------------------------------------------------------------OnAfterGetRecordBOMLoopOnAfterGetCompItem:BEGIN
    [IntegrationEvent(false, false)]
    local procedure OnAfterGetRecordBOMLoopOnAfterGetCompItem(MfgItem: Record Item; var ProductionBOMLine: array[99] of Record "Production BOM Line"; var CompItem: Record Item; Index: Integer;)
    begin
    end;
    //----------------------------------------------------------------OnAfterGetRecordBOMLoopOnAfterGetCompItem:END

Internal work item: AB#604899

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventships-in-future-updateFix ships in a future update

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions