Table extension 20517 Subc. Transfer Line
src/Apps/W1/Subcontracting/App/src/Transfer/SubcTransferLine.TableExt.al252 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.Manufacturing.Subcontracting;using Microsoft.Foundation.Enums;using Microsoft.Foundation.UOM;using Microsoft.Inventory.Item;using Microsoft.Inventory.Tracking;using Microsoft.Inventory.Transfer;using Microsoft.Manufacturing.Document;using Microsoft.Manufacturing.Routing;using Microsoft.Manufacturing.WorkCenter;using Microsoft.Warehouse.Document;tableextension 20517 "Subc. Transfer Line" extends "Transfer Line"{ AllowInCustomizations = AsReadOnly; fields { field(20530; "Subc. Purch. Order No."; Code[20]) { Caption = 'Subc. Purch. Order No.'; DataClassification = CustomerContent; ToolTip = 'Specifies the number of the related purchase order.'; } field(20531; "Subc. Purch. Order Line No."; Integer) { Caption = 'Subc. Purch. Order Line No.'; DataClassification = CustomerContent; ToolTip = 'Specifies the number of the related purchase order line.'; } field(20532; "Subc. Prod. Order No."; Code[20]) { Caption = 'Subc. Prod. Order No.'; DataClassification = CustomerContent; TableRelation = "Production Order"."No." where(Status = const(Released)); ToolTip = 'Specifies the number of the related production order.'; } field(20533; "Subc. Prod. Order Line No."; Integer) { Caption = 'Subc. Prod. Order Line No.'; DataClassification = CustomerContent; TableRelation = "Prod. Order Line"."Line No." where(Status = const(Released), "Prod. Order No." = field("Subc. Prod. Order No.")); ToolTip = 'Specifies the number of the related production order line.'; } field(20534; "Subc. Prod. Ord. Comp Line No."; Integer) { Caption = 'Subc. Prod. Order Comp. Line No.'; DataClassification = CustomerContent; TableRelation = "Prod. Order Component"."Line No." where(Status = const(Released), "Prod. Order No." = field("Subc. Prod. Order No."), "Prod. Order Line No." = field("Subc. Prod. Order Line No.")); ToolTip = 'Specifies the line number of the related production order component line.'; } field(20535; "Subc. Routing No."; Code[20]) { Caption = 'Subc. Routing No.'; DataClassification = CustomerContent; TableRelation = "Routing Header"; ToolTip = 'Specifies the number of the related production routing.'; } field(20536; "Subc. Routing Reference No."; Integer) { Caption = 'Subc. Routing Reference No.'; DataClassification = CustomerContent; ToolTip = 'Specifies the number of the related production routing reference no.'; } field(20537; "Subc. Work Center No."; Code[20]) { Caption = 'Subc. Work Center No.'; DataClassification = CustomerContent; TableRelation = "Work Center"; ToolTip = 'Specifies the number of the related production work center.'; } field(20538; "Subc. Operation No."; Code[10]) { Caption = 'Subc. Operation No.'; DataClassification = CustomerContent; TableRelation = "Prod. Order Routing Line"."Operation No." where(Status = const(Released), "Prod. Order No." = field("Subc. Prod. Order No."), "Routing No." = field("Subc. Routing No.")); ToolTip = 'Specifies the number of the related production operation no.'; } field(20539; "Subc. Return Order"; Boolean) { Caption = 'Subc. Return Order'; DataClassification = CustomerContent; Editable = false; ToolTip = 'Specifies whether the existing transfer order is a return of the subcontractor.'; } field(20560; "Transfer WIP Item"; Boolean) { Caption = 'Transfer WIP Item'; DataClassification = CustomerContent; Editable = false; ToolTip = 'Specifies whether this transfer line represents a WIP item transfer. When enabled, a WIP item transfer can be created.'; trigger OnValidate() var Item: Record Item; UnitOfMeasureManagement: Codeunit "Unit of Measure Management"; begin#if not CLEAN29#pragma warning disable AL0432 if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432 exit;#endif if "Transfer WIP Item" then begin CheckForExistingReservationsOrItemTracking(); "Qty. per Unit of Measure" := 0; end else begin Item.SetLoadFields("Base Unit of Measure"); Item.Get(Rec."Item No."); "Qty. per Unit of Measure" := UnitOfMeasureManagement.GetQtyPerUnitOfMeasure(Item, "Unit of Measure Code"); end; UpdateDescriptions(); Validate(Quantity); end; } field(20561; "Whse. Inbnd. Otsdg. Qty"; Decimal) { AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Warehouse Receipt Line"."Qty. Outstanding" where("Source Type" = const(5741), "Source Subtype" = const("1"), "Source No." = field("Document No."), "Source Line No." = field("Line No."))); Caption = 'Whse. Inbnd. Otsdg. Qty'; DecimalPlaces = 0 : 5; Editable = false; FieldClass = FlowField; ToolTip = 'Specifies the outstanding quantity on warehouse receipts for this transfer line.'; } field(20562; "Whse Outbnd. Otsdg. Qty"; Decimal) { AutoFormatType = 0; BlankZero = true; CalcFormula = sum("Warehouse Shipment Line"."Qty. Outstanding" where("Source Type" = const(5741), "Source Subtype" = const("0"), "Source No." = field("Document No."), "Source Line No." = field("Line No."))); Caption = 'Whse Outbnd. Otsdg. Qty'; DecimalPlaces = 0 : 5; Editable = false; FieldClass = FlowField; ToolTip = 'Specifies the outstanding quantity on warehouse shipments for this transfer line.'; } field(20563; "Prev. Operation No."; Code[10]) { AllowInCustomizations = AsReadOnly; Caption = 'Previous Operation No.'; DataClassification = CustomerContent; Editable = false; TableRelation = "Prod. Order Routing Line"."Operation No." where(Status = const(Released), "Prod. Order No." = field("Subc. Prod. Order No."), "Routing No." = field("Subc. Routing No.")); ToolTip = 'Specifies the number of the related previous production operation no.'; } } keys { key(Key99001500; "Subc. Purch. Order No.", "Subc. Purch. Order Line No.", "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Prod. Ord. Comp Line No.") { } key(Key99001501; "Subc. Prod. Order No.", "Subc. Routing No.", "Subc. Routing Reference No.", "Subc. Operation No.", "Subc. Purch. Order No.") { } key(Key99001502; "Subc. Purch. Order No.", "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Operation No.") { } key(Key99001503; "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Routing Reference No.", "Subc. Routing No.", "Subc. Operation No.") { } key(Key99001504; "Subc. Prod. Order No.", "Subc. Prod. Order Line No.", "Subc. Prod. Ord. Comp Line No.", "Subc. Purch. Order No.", "Subc. Return Order") { } }#if not CLEAN29 var#pragma warning disable AL0432 SubcFeatureFlagHandler: Codeunit "Subc. Feature Flag Handler";#pragma warning restore AL0432#endif internal procedure CheckForExistingReservationsOrItemTracking() var ReservationEntry: Record "Reservation Entry"; ExistingReservationsErr: Label 'There are existing reservations for this transfer line. Please remove the reservations before changing the line to/from a WIP item transfer.'; ExistingItemTrackingErr: Label 'There is existing item tracking for this transfer line. Please remove the item tracking before changing the line to/from a WIP item transfer.'; ExistingReservationEntriesErr: Label 'There are existing reservation entries for this transfer line. Please remove the reservation entries before changing the line to/from a WIP item transfer.'; begin#if not CLEAN29#pragma warning disable AL0432 if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432 exit;#endif Rec.SetReservationFilters(ReservationEntry, "Transfer Direction"::Outbound); ReservationEntry.SetRange("Reservation Status", "Reservation Status"::Reservation); if not ReservationEntry.IsEmpty() then Error(ExistingReservationsErr); ReservationEntry.Reset(); Rec.SetReservationFilters(ReservationEntry, "Transfer Direction"::Inbound); ReservationEntry.SetRange("Reservation Status", "Reservation Status"::Reservation); if not ReservationEntry.IsEmpty() then Error(ExistingReservationsErr); ReservationEntry.Reset(); Rec.SetReservationFilters(ReservationEntry, "Transfer Direction"::Outbound); ReservationEntry.SetRange("Source Subtype");//Ignore Direction ReservationEntry.SetRange("Reservation Status", "Reservation Status"::Surplus); if not ReservationEntry.IsEmpty() then Error(ExistingItemTrackingErr); if Rec.ReservEntryExist() then Error(ExistingReservationEntriesErr); end; procedure CalcBaseQty(Quantity: Decimal) BaseQty: Decimal var Item: Record Item; UnitOfMeasureManagement: Codeunit "Unit of Measure Management"; QtyPerUoM: Decimal; begin#if not CLEAN29#pragma warning disable AL0432 if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432 exit;#endif Item.SetLoadFields("Base Unit of Measure"); Item.Get("Item No."); QtyPerUoM := UnitOfMeasureManagement.GetQtyPerUnitOfMeasure(Item, "Unit of Measure Code"); BaseQty := UnitOfMeasureManagement.CalcBaseQty(Quantity, QtyPerUoM); end; internal procedure UpdateDescriptions() var ProdOrderRoutingLine: Record "Prod. Order Routing Line"; begin#if not CLEAN29#pragma warning disable AL0432 if not SubcFeatureFlagHandler.IsSubcontractingEnabled() then#pragma warning restore AL0432 exit;#endif if Rec."Transfer WIP Item" then if ProdOrderRoutingLine.Get("Production Order Status"::Released, "Subc. Prod. Order No.", "Subc. Routing Reference No.", "Subc. Routing No.", "Subc. Operation No.") then begin if ProdOrderRoutingLine."Transfer Description" <> '' then Rec.Description := ProdOrderRoutingLine."Transfer Description"; if ProdOrderRoutingLine."Transfer Description 2" <> '' then Rec."Description 2" := ProdOrderRoutingLine."Transfer Description 2"; end; end;}