Page 99000898 Available - Prod. Order Comp.
src/Layers/W1/BaseApp/Manufacturing/Document/AvailableProdOrderComp.Page.al321 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.Document;using Microsoft.Foundation.Enums;using Microsoft.Inventory.Item;using Microsoft.Inventory.Tracking;page 99000898 "Available - Prod. Order Comp."{ Caption = 'Available - Prod. Order Comp.'; DataCaptionExpression = CaptionText; DeleteAllowed = false; Editable = false; InsertAllowed = false; ModifyAllowed = false; PageType = List; SourceTable = "Prod. Order Component"; SourceTableView = sorting(Status, "Item No.", "Variant Code", "Location Code", "Due Date"); layout { area(content) { repeater(Control1) { ShowCaption = false; field("Prod. Order No."; Rec."Prod. Order No.") { ApplicationArea = Manufacturing; } field(Status; Rec.Status) { ApplicationArea = Manufacturing; } field("Location Code"; Rec."Location Code") { ApplicationArea = Location; ToolTip = 'Specifies the location where the component is stored. It is copied from the corresponding field on the production order line.'; } field("Due Date"; Rec."Due Date") { ApplicationArea = Manufacturing; ToolTip = 'Specifies the date when the production order component must be available for consumption. The date is copied from the Starting Date field on the related production order line.'; } field("Remaining Quantity"; Rec."Remaining Quantity") { ApplicationArea = Manufacturing; } field("Reserved Qty. (Base)"; Rec."Reserved Qty. (Base)") { ApplicationArea = Reservation; Editable = false; ToolTip = 'Specifies the reserved quantity of the item in base units of measure.'; } field(QtyToReserveBase; QtyToReserveBase) { ApplicationArea = Manufacturing; AutoFormatType = 0; Caption = 'Available Quantity'; DecimalPlaces = 0 : 5; Editable = false; ToolTip = 'Specifies the quantity of the item that is available.'; } field(ReservedQuantity; GetReservedQtyInLine()) { ApplicationArea = Reservation; AutoFormatType = 0; Caption = 'Current Reserved Quantity'; DecimalPlaces = 0 : 5; ToolTip = 'Specifies the quantity of the item that is reserved for the document type.'; trigger OnDrillDown() begin ReservEntry2.Reset(); Rec.SetReservationFilters(ReservEntry2); ReservEntry2.SetRange("Reservation Status", ReservEntry2."Reservation Status"::Reservation); ReservMgt.MarkReservConnection(ReservEntry2, ReservEntry); PAGE.RunModal(PAGE::"Reservation Entries", ReservEntry2); UpdateReservFrom(); CurrPage.Update(); end; } } } area(factboxes) { systempart(Control1900383207; Links) { ApplicationArea = RecordLinks; Visible = false; } systempart(Control1905767507; Notes) { ApplicationArea = Notes; Visible = false; } } } actions { area(navigation) { group("&Line") { Caption = '&Line'; Image = Line; action("Item &Tracking Lines") { ApplicationArea = ItemTracking; Caption = 'Item &Tracking Lines'; Image = ItemTrackingLines; ShortCutKey = 'Ctrl+Alt+I'; ToolTip = 'View or edit serial, lot and package numbers that are assigned to the item on the document or journal line.'; trigger OnAction() begin Rec.OpenItemTrackingLines(); end; } } } area(processing) { group("F&unctions") { Caption = 'F&unctions'; Image = "Action"; action(Reserve) { ApplicationArea = Reservation; Caption = '&Reserve'; Image = Reserve; ToolTip = 'Reserve the quantity that is required on the document line that you opened this window for.'; trigger OnAction() begin ReservEntry.LockTable(); UpdateReservMgt(); Rec.GetReservationQty(QtyReserved, QtyReservedBase, QtyToReserve, QtyToReserveBase); ReservMgt.CalculateRemainingQty(NewQtyReserved, NewQtyReservedBase); ReservMgt.CopySign(NewQtyReserved, QtyToReserve); ReservMgt.CopySign(NewQtyReservedBase, QtyToReserveBase); if NewQtyReservedBase <> 0 then if NewQtyReservedBase > QtyToReserveBase then CreateReservation(QtyToReserve, QtyToReserveBase) else CreateReservation(NewQtyReserved, NewQtyReservedBase) else Error(Text000); end; } action(CancelReservation) { AccessByPermission = TableData Item = R; ApplicationArea = Reservation; Caption = '&Cancel Reservation'; Image = Cancel; ToolTip = 'Cancel the reservation that exists for the document line that you opened this window for.'; trigger OnAction() begin if not Confirm(Text001, false) then exit; ReservEntry2.Copy(ReservEntry); Rec.SetReservationFilters(ReservEntry2); if ReservEntry2.Find('-') then begin UpdateReservMgt(); repeat ReservEngineMgt.CancelReservation(ReservEntry2); until ReservEntry2.Next() = 0; UpdateReservFrom(); end; end; } } } } trigger OnAfterGetRecord() begin Rec.GetReservationQty(QtyReserved, QtyReservedBase, QtyToReserve, QtyToReserveBase); end; trigger OnOpenPage() begin ReservEntry.TestField("Source Type"); SetFilters(); end; var ReservEntry2: Record "Reservation Entry"; ReservMgt: Codeunit "Reservation Management"; ReservEngineMgt: Codeunit "Reservation Engine Mgt."; NewQtyReserved: Decimal; NewQtyReservedBase: Decimal; CaptionText: Text; CurrentSubType: Option;#pragma warning disable AA0074 Text000: Label 'Fully reserved.'; Text001: Label 'Do you want to cancel the reservation?';#pragma warning disable AA0470 Text002: Label 'Available Quantity is %1.';#pragma warning restore AA0470#pragma warning restore AA0074 protected var ReservEntry: Record "Reservation Entry"; SourceRecRef: RecordRef; QtyToReserve: Decimal; QtyReserved: Decimal; QtyToReserveBase: Decimal; QtyReservedBase: Decimal; procedure SetSource(CurrentSourceRecRef: RecordRef; CurrentReservEntry: Record "Reservation Entry") var TransferDirection: Enum "Transfer Direction"; begin SetSource(CurrentSourceRecRef, CurrentReservEntry, TransferDirection::Outbound); end; procedure SetSource(CurrentSourceRecRef: RecordRef; CurrentReservEntry: Record "Reservation Entry"; Direction: Enum "Transfer Direction") begin Clear(ReservMgt); SourceRecRef := CurrentSourceRecRef; ReservEntry := CurrentReservEntry; ReservMgt.TestItemType(SourceRecRef); ReservMgt.SetReservSource(SourceRecRef, Direction); CaptionText := ReservMgt.FilterReservFor(SourceRecRef, ReservEntry, Direction); end; local procedure CreateReservation(ReserveQuantity: Decimal; ReserveQuantityBase: Decimal) var TrackingSpecification: Record "Tracking Specification"; begin Rec.CalcFields("Reserved Qty. (Base)"); if Rec."Remaining Qty. (Base)" + Rec."Reserved Qty. (Base)" < ReserveQuantityBase then Error(Text002, Rec."Remaining Qty. (Base)" + Rec."Reserved Qty. (Base)"); Rec.TestField("Item No.", ReservEntry."Item No."); Rec.TestField("Variant Code", ReservEntry."Variant Code"); Rec.TestField("Location Code", ReservEntry."Location Code"); UpdateReservMgt(); TrackingSpecification.InitTrackingSpecification( Database::"Prod. Order Component", Rec.Status.AsInteger(), Rec."Prod. Order No.", '', Rec."Prod. Order Line No.", Rec."Line No.", Rec."Variant Code", Rec."Location Code", Rec."Qty. per Unit of Measure"); ReservMgt.CreateReservation( ReservEntry.Description, Rec."Due Date", ReserveQuantity, ReserveQuantityBase, TrackingSpecification); UpdateReservFrom(); end; local procedure UpdateReservFrom() begin SetSource(SourceRecRef, ReservEntry, ReservEntry.GetTransferDirection()); OnAfterUpdateReservFrom(ReservEntry); end; local procedure UpdateReservMgt() begin Clear(ReservMgt); ReservMgt.SetReservSource(SourceRecRef, ReservEntry.GetTransferDirection()); OnAfterUpdateReservMgt(ReservEntry); end; protected procedure GetReservedQtyInLine(): Decimal begin ReservEntry2.Reset(); Rec.SetReservationFilters(ReservEntry2); ReservEntry2.SetRange("Reservation Status", ReservEntry2."Reservation Status"::Reservation); exit(ReservMgt.MarkReservConnection(ReservEntry2, ReservEntry)); end; procedure SetCurrentSubType(SubType: Option) begin CurrentSubType := SubType; end; local procedure SetFilters() begin Rec.SetRange(Status, CurrentSubType); Rec.SetRange("Item No.", ReservEntry."Item No."); Rec.SetRange("Variant Code", ReservEntry."Variant Code"); Rec.SetRange("Location Code", ReservEntry."Location Code"); Rec.SetFilter("Due Date", ReservMgt.GetAvailabilityFilter(ReservEntry."Shipment Date")); if ReservMgt.IsPositive() then Rec.SetFilter("Remaining Qty. (Base)", '<0') else Rec.SetFilter("Remaining Qty. (Base)", '>0'); OnAfterSetFilters(Rec, ReservEntry); end; [IntegrationEvent(false, false)] local procedure OnAfterSetFilters(var ProdOrderComponent: Record "Prod. Order Component"; ReservationEntry: Record "Reservation Entry") begin end; [IntegrationEvent(true, false)] local procedure OnAfterUpdateReservFrom(var ReservationEntry: Record "Reservation Entry") begin end; [IntegrationEvent(true, false)] local procedure OnAfterUpdateReservMgt(var ReservationEntry: Record "Reservation Entry") begin end;}