Codeunit 9136 Check BOM Component

Base Application, Microsoft.Inventory.BOM

src/Layers/W1/BaseApp/Inventory/BOM/CheckBOMComponent.Codeunit.al48 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Inventory.BOM;using Microsoft.Inventory.Item;codeunit 9136 "Check BOM Component"{    [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterCheckDocuments', '', false, false)]    local procedure ItemOnBeforeCheckDocuments(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text);    begin        CheckBOMComponents(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption);    end;    internal procedure CheckBOMComponents(var Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text)    var        BOMComponent: Record "BOM Component";        IsHandled: Boolean;    begin        IsHandled := false;        OnBeforeCheckBOMComponents(Item, CurrentFieldNo, CheckFieldNo, CheckFieldCaption, IsHandled);        if IsHandled then            exit;        BOMComponent.Reset();        BOMComponent.SetCurrentKey(Type, "No.");        BOMComponent.SetRange(Type, BOMComponent.Type::Item);        BOMComponent.SetRange("No.", Item."No.");        if not BOMComponent.IsEmpty() then begin            if CurrentFieldNo = 0 then                Error(                    Item.GetCannotDeleteItemWithExistingDocumentLinesErr(),                    Item.TableCaption(), Item."No.", BOMComponent.TableCaption());            if CurrentFieldNo = CheckFieldNo then                Error(                    Item.GetCannotChangeItemWithExistingDocumentLinesErr(),                    CheckFieldCaption, Item.TableCaption(), Item."No.", BOMComponent.TableCaption());        end;    end;    [IntegrationEvent(false, false)]    local procedure OnBeforeCheckBOMComponents(Item: Record Item; CurrentFieldNo: Integer; CheckFieldNo: Integer; CheckFieldCaption: Text; var IsHandled: Boolean)    begin    end;}