Page 7352 Put-away Worksheet

Base Application, Microsoft.Warehouse.Worksheet

src/Layers/W1/BaseApp/Warehouse/Worksheet/PutawayWorksheet.Page.al602 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.Warehouse.Worksheet;using Microsoft.Inventory.Item;using Microsoft.Inventory.Ledger;using Microsoft.Warehouse.Activity;using Microsoft.Warehouse.Journal;using Microsoft.Warehouse.Ledger;using Microsoft.Warehouse.Request;using Microsoft.Warehouse.Structure;using System.Environment;using System.Environment.Configuration;using System.Integration;using System.Integration.Excel;page 7352 "Put-away Worksheet"{    ApplicationArea = Warehouse;    Caption = 'Put-away Worksheets';    DataCaptionFields = Name;    InsertAllowed = false;    PageType = Worksheet;    RefreshOnActivate = true;    SaveValues = true;    SourceTable = "Whse. Worksheet Line";    SourceTableView = sorting("Worksheet Template Name", Name, "Location Code", "Sorting Sequence No.");    UsageCategory = Tasks;    layout    {        area(content)        {            field(CurrentWkshName; CurrentWkshName)            {                ApplicationArea = Warehouse;                Caption = 'Name';                Lookup = true;                ToolTip = 'Specifies the name of the worksheet in which you can organize various kinds of put-aways, including put-aways with lines from several orders.';                trigger OnLookup(var Text: Text): Boolean                begin                    CurrPage.SaveRecord();                    Rec.LookupWhseWkshName(Rec, CurrentWkshName, CurrentLocationCode);                    CurrPage.Update(false);                end;                trigger OnValidate()                begin                    Rec.CheckWhseWkshName(CurrentWkshName, CurrentLocationCode, Rec);                    CurrentWkshNameOnAfterValidate();                end;            }            field(CurrentLocationCode; CurrentLocationCode)            {                ApplicationArea = Warehouse;                Caption = 'Location Code';                Editable = false;                ToolTip = 'Specifies the location that is set up to use directed put-away.';            }            field(CurrentSortingMethod; CurrentSortingMethod)            {                ApplicationArea = Warehouse;                Caption = 'Sorting Method';                ToolTip = 'Specifies the method by which the warehouse internal put-away lines are sorted.';                trigger OnValidate()                begin                    CurrentSortingMethodOnAfterValidate();                end;            }            repeater(Control1)            {                ShowCaption = false;                field("Whse. Document Type"; Rec."Whse. Document Type")                {                    ApplicationArea = Warehouse;                    Visible = false;                }                field(WhseDocumentType; WhseDocumentType)                {                    ApplicationArea = Warehouse;                    Caption = 'Whse. Document Type';                    ToolTip = 'Specifies the type of warehouse document this line is associated with.';                    trigger OnValidate()                    begin                        Rec.Validate("Whse. Document Type", WhseDocumentType);                    end;                }                field("Whse. Document No."; Rec."Whse. Document No.")                {                    ApplicationArea = Warehouse;                }                field("Whse. Document Line No."; Rec."Whse. Document Line No.")                {                    ApplicationArea = Warehouse;                    Visible = false;                }                field("Item No."; Rec."Item No.")                {                    ApplicationArea = Warehouse;                    Editable = false;                    trigger OnValidate()                    begin                        Rec.GetItem(Rec."Item No.", ItemDescription);                    end;                }                field("Variant Code"; Rec."Variant Code")                {                    ApplicationArea = Planning;                    Editable = false;                    Visible = false;                }                field(Description; Rec.Description)                {                    ApplicationArea = Warehouse;                    Editable = false;                }                field("Description 2"; Rec."Description 2")                {                    ApplicationArea = Warehouse;                    Visible = false;                }                field("From Zone Code"; Rec."From Zone Code")                {                    ApplicationArea = Warehouse;                    Editable = false;                    Visible = false;                }                field("From Bin Code"; Rec."From Bin Code")                {                    ApplicationArea = Warehouse;                    Editable = false;                    Visible = false;                }                field("Shelf No."; Rec."Shelf No.")                {                    ApplicationArea = Warehouse;                    Visible = false;                }                field(Quantity; Rec.Quantity)                {                    ApplicationArea = Warehouse;                    Editable = false;                }                field("Qty. (Base)"; Rec."Qty. (Base)")                {                    ApplicationArea = Warehouse;                    ToolTip = 'Specifies the quantity that should be handled in the base unit of measure.';                    Visible = false;                }                field("Qty. Outstanding"; Rec."Qty. Outstanding")                {                    ApplicationArea = Warehouse;                }                field("Qty. Outstanding (Base)"; Rec."Qty. Outstanding (Base)")                {                    ApplicationArea = Warehouse;                    ToolTip = 'Specifies the quantity that still needs to be handled, expressed in the base unit of measure.';                    Visible = false;                }                field("Qty. to Handle"; Rec."Qty. to Handle")                {                    ApplicationArea = Warehouse;                    trigger OnValidate()                    begin                        QtytoHandleOnAfterValidate();                    end;                }                field("Qty. to Handle (Base)"; Rec."Qty. to Handle (Base)")                {                    ApplicationArea = Warehouse;                    ToolTip = 'Specifies the quantity you want to handle, in the base unit of measure.';                    Visible = false;                }                field("Qty. Handled"; Rec."Qty. Handled")                {                    ApplicationArea = Warehouse;                }                field("Qty. Handled (Base)"; Rec."Qty. Handled (Base)")                {                    ApplicationArea = Warehouse;                    ToolTip = 'Specifies the quantity that has been handled and registered, in the base unit of measure.';                    Visible = false;                }                field("Due Date"; Rec."Due Date")                {                    ApplicationArea = Warehouse;                }                field("Unit of Measure Code"; Rec."Unit of Measure Code")                {                    ApplicationArea = Warehouse;                    Editable = false;                }            }            group(Control22)            {                ShowCaption = false;                fixed(Control1900669001)                {                    ShowCaption = false;                    group("Item Description")                    {                        Caption = 'Item Description';                        field(ItemDescription; ItemDescription)                        {                            ApplicationArea = Warehouse;                            Editable = false;                            ShowCaption = false;                        }                    }                }            }        }        area(factboxes)        {            part(Control8; "Lot Numbers by Bin FactBox")            {                ApplicationArea = Warehouse;                SubPageLink = "Item No." = field("Item No."),                              "Variant Code" = field("Variant Code"),                              "Location Code" = field("Location Code");                Visible = false;            }            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;                Visible = false;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;                Visible = false;            }        }    }    actions    {        area(navigation)        {            group("&Line")            {                Caption = '&Line';                Image = Line;                action("Source &Document Line")                {                    ApplicationArea = Warehouse;                    Caption = 'Source &Document Line';                    Image = SourceDocLine;                    Scope = Repeater;                    ToolTip = 'View the line on a released source document that the warehouse activity is for. ';                    trigger OnAction()                    begin                        WMSMgt.ShowSourceDocLine(                          Rec."Source Type", Rec."Source Subtype", Rec."Source No.", Rec."Source Line No.", Rec."Source Subline No.");                    end;                }                action("Whse. Document Line")                {                    ApplicationArea = Warehouse;                    Caption = 'Whse. Document Line';                    Image = Line;                    Scope = Repeater;                    ToolTip = 'View the line on another warehouse document that the warehouse activity is for.';                    trigger OnAction()                    begin                        WMSMgt.ShowWhseActivityDocLine(                            Rec."Whse. Document Type", Rec."Whse. Document No.", Rec."Whse. Document Line No.");                    end;                }                action("Item &Tracking Lines")                {                    ApplicationArea = ItemTracking;                    Caption = 'Item &Tracking Lines';                    Image = ItemTrackingLines;                    Scope = Repeater;                    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;                }            }            group("&Item")            {                Caption = '&Item';                Image = Item;                action(Card)                {                    ApplicationArea = Warehouse;                    Caption = 'Card';                    Image = EditLines;                    RunObject = Page "Item Card";                    RunPageLink = "No." = field("Item No.");                    Scope = Repeater;                    ShortCutKey = 'Shift+F7';                    ToolTip = 'View or change detailed information about the record on the document or journal line.';                }                action("Warehouse Entries")                {                    ApplicationArea = Warehouse;                    Caption = 'Warehouse Entries';                    Image = BinLedger;                    RunObject = Page "Warehouse Entries";                    RunPageLink = "Item No." = field("Item No."),                                  "Variant Code" = field("Variant Code"),                                  "Location Code" = field("Location Code");                    RunPageView = sorting("Item No.", "Location Code", "Variant Code");                    Scope = Repeater;                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View completed warehouse activities related to the document.';                }                action("Ledger E&ntries")                {                    ApplicationArea = Warehouse;                    Caption = 'Ledger E&ntries';                    Image = ItemLedger;                    RunObject = Page "Item Ledger Entries";                    RunPageLink = "Item No." = field("Item No."),                                  "Variant Code" = field("Variant Code"),                                  "Location Code" = field("Location Code");                    RunPageView = sorting("Item No.");                    Scope = Repeater;                    ToolTip = 'View the history of transactions that have been posted for the selected record.';                }                action("Bin Contents")                {                    ApplicationArea = Warehouse;                    Caption = 'Bin Contents';                    Image = BinContent;                    RunObject = Page "Bin Contents List";                    RunPageLink = "Location Code" = field("Location Code"),                                  "Item No." = field("Item No."),                                  "Variant Code" = field("Variant Code");                    RunPageView = sorting("Location Code", "Item No.", "Variant Code");                    Scope = Repeater;                    ToolTip = 'View items in the bin if the selected line contains a bin code.';                }            }        }        area(processing)        {            group("F&unctions")            {                Caption = 'F&unctions';                Image = "Action";                action(GetWarehouseDocuments)                {                    ApplicationArea = Warehouse;                    Caption = 'Get Warehouse Documents';                    Ellipsis = true;                    Image = GetSourceDoc;                    ShortCutKey = 'Shift+F11';                    ToolTip = 'Select a warehouse document to pick for, such as a warehouse shipment.';                    trigger OnAction()                    var                        GetWhsePutAwayDoc: Codeunit "Get Source Doc. Inbound";                    begin                        OnBeforeGetWarehouseDocuments();                        GetWhsePutAwayDoc.GetSingleWhsePutAwayDoc(                          CurrentWkshTemplateName, CurrentWkshName, CurrentLocationCode);                        Rec.SortWhseWkshLines(                          CurrentWkshTemplateName, CurrentWkshName,                          CurrentLocationCode, CurrentSortingMethod);                    end;                }                action("Autofill Qty. to Handle")                {                    ApplicationArea = Warehouse;                    Caption = 'Autofill Qty. to Handle';                    Image = AutofillQtyToHandle;                    Scope = Repeater;                    ToolTip = 'Have the system enter the outstanding quantity in the Qty. to Handle field.';                    trigger OnAction()                    var                        WhseWkshLine: Record "Whse. Worksheet Line";                    begin                        WhseWkshLine.Copy(Rec);                        Rec.AutofillQtyToHandle(WhseWkshLine);                    end;                }                action("Delete Qty. to Handle")                {                    ApplicationArea = Warehouse;                    Caption = 'Delete Qty. to Handle';                    Image = DeleteQtyToHandle;                    Scope = Repeater;                    ToolTip = 'Have the system clear the value in the Qty. To Handle field. ';                    trigger OnAction()                    var                        WhseWkshLine: Record "Whse. Worksheet Line";                    begin                        WhseWkshLine.Copy(Rec);                        Rec.DeleteQtyToHandle(WhseWkshLine);                    end;                }                action(CreatePutAway)                {                    ApplicationArea = Warehouse;                    Caption = 'Create Put-away';                    Ellipsis = true;                    Image = CreatePutAway;                    Scope = Repeater;                    ToolTip = 'Create warehouse put-away documents for the specified put-aways. ';                    trigger OnAction()                    var                        WhseWkshLine: Record "Whse. Worksheet Line";                    begin                        WhseWkshLine.CopyFilters(Rec);                        if WhseWkshLine.FindFirst() then                            Rec.PutAwayCreate(WhseWkshLine)                        else                            Error(Text001);                    end;                }            }            group("Page")            {                Caption = 'Page';                action(EditInExcel)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Edit in Excel';                    Image = Excel;                    ToolTip = 'Send the data in the worksheet to an Excel file for analysis or editing.';                    Visible = IsSaaSExcelAddinEnabled;                    AccessByPermission = System "Allow Action Export To Excel" = X;                    trigger OnAction()                    var                        EditinExcel: Codeunit "Edit in Excel";                        EditinExcelFilters: Codeunit "Edit in Excel Filters";                        ODataUtility: Codeunit "ODataUtility";                    begin                        EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec.Name)), Enum::"Edit in Excel Filter Type"::Equal, CurrentWkshName, Enum::"Edit in Excel Edm Type"::"Edm.String");                        EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec."Worksheet Template Name")), Enum::"Edit in Excel Filter Type"::Equal, CurrentWkshTemplateName, Enum::"Edit in Excel Edm Type"::"Edm.String");                        EditinExcelFilters.AddFieldV2(ODataUtility.ExternalizeName(Rec.FieldName(Rec."Location Code")), Enum::"Edit in Excel Filter Type"::Equal, CurrentLocationCode, Enum::"Edit in Excel Edm Type"::"Edm.String");                        EditinExcel.EditPageInExcel(Text.CopyStr(CurrPage.Caption, 1, 240), Page::"Put-away Worksheet", EditInExcelFilters, StrSubstNo(ExcelFileNameTxt, CurrentWkshName, CurrentWkshTemplateName));                    end;                }            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.';                actionref(GetWarehouseDocuments_Promoted; GetWarehouseDocuments)                {                }                actionref(CreatePutAway_Promoted; CreatePutAway)                {                }                group("Category_Qty. to Handle")                {                    Caption = 'Qty. to Handle';                    ShowAs = SplitButton;                    actionref("Autofill Qty. to Handle_Promoted"; "Autofill Qty. to Handle")                    {                    }                    actionref("Delete Qty. to Handle_Promoted"; "Delete Qty. to Handle")                    {                    }                }            }            group(Category_Category4)            {                Caption = 'Prepare', Comment = 'Generated from the PromotedActionCategories property index 3.';            }            group(Category_Category5)            {                Caption = 'Line', Comment = 'Generated from the PromotedActionCategories property index 4.';                actionref("Source &Document Line_Promoted"; "Source &Document Line")                {                }                actionref("Whse. Document Line_Promoted"; "Whse. Document Line")                {                }                actionref("Item &Tracking Lines_Promoted"; "Item &Tracking Lines")                {                }            }            group(Category_Category6)            {                Caption = 'Item', Comment = 'Generated from the PromotedActionCategories property index 5.';                actionref(Card_Promoted; Card)                {                }                actionref("Warehouse Entries_Promoted"; "Warehouse Entries")                {                }            }            group(Category_Report)            {                Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';            }        }    }    trigger OnAfterGetCurrRecord()    begin        Rec.GetItem(Rec."Item No.", ItemDescription);        WhseDocumentType := Rec."Whse. Document Type";    end;    trigger OnAfterGetRecord()    begin        WhseDocumentType := Rec."Whse. Document Type";    end;    trigger OnDeleteRecord(): Boolean    begin        ItemDescription := '';    end;    trigger OnOpenPage()    var        ClientTypeManagement: Codeunit "Client Type Management";        ServerSetting: Codeunit "Server Setting";        WhseWkshSelected: Boolean;    begin        IsSaaSExcelAddinEnabled := ServerSetting.GetIsSaasExcelAddinEnabled();        // if called from API (such as edit-in-excel), do not filter         if ClientTypeManagement.GetCurrentClientType() = CLIENTTYPE::ODataV4 then            exit;        OpenedFromBatch := (Rec.Name <> '') and (Rec."Worksheet Template Name" = '');        if OpenedFromBatch then begin            CurrentWkshName := Rec.Name;            CurrentLocationCode := Rec."Location Code";            Rec.OpenWhseWksh(Rec, CurrentWkshTemplateName, CurrentWkshName, CurrentLocationCode);            exit;        end;        Rec.TemplateSelection(PAGE::"Put-away Worksheet", 0, Rec, WhseWkshSelected);        if not WhseWkshSelected then            Error('');        Rec.OpenWhseWksh(Rec, CurrentWkshTemplateName, CurrentWkshName, CurrentLocationCode);    end;    var        WMSMgt: Codeunit "WMS Management";        ItemDescription: Text[100];#pragma warning disable AA0074        Text001: Label 'There is nothing to handle.';#pragma warning restore AA0074        ExcelFileNameTxt: Label 'Put-away Worksheet - WorksheetName %1 - WorksheetTemplateName %2', Comment = '%1 = Worksheet Name; %2 = Worksheet Template Name';        OpenedFromBatch: Boolean;        IsSaaSExcelAddinEnabled: Boolean;        WhseDocumentType: Enum "Warehouse Putaway Document Type";    protected var        CurrentWkshTemplateName: Code[10];        CurrentWkshName: Code[10];        CurrentLocationCode: Code[10];        CurrentSortingMethod: Enum "Whse. Activity Sorting Method";    protected procedure QtytoHandleOnAfterValidate()    begin        CurrPage.Update();    end;    protected procedure CurrentWkshNameOnAfterValidate()    begin        CurrPage.SaveRecord();        Rec.SetWhseWkshName(CurrentWkshName, CurrentLocationCode, Rec);        CurrPage.Update(false);    end;    protected procedure CurrentSortingMethodOnAfterValidate()    begin        Rec.SortWhseWkshLines(          CurrentWkshTemplateName, CurrentWkshName,          CurrentLocationCode, CurrentSortingMethod);        CurrPage.Update(false);        Rec.SetCurrentKey("Worksheet Template Name", Name, "Location Code", "Sorting Sequence No.");    end;    [IntegrationEvent(true, false)]    local procedure OnBeforeGetWarehouseDocuments();    begin    end;}