ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Page 491 and 9231 - add Lot No. Filter

Open hhout opened this issue 7 years ago • 1 comments

We need to have the possibillity to use extra filters on page 491, we would like to use this page with Lot No. Filter.

On Page 491 we need the modification (or an Event if possible) to set the Lot No. Filter: Code

                field(LotNoFilter; LotNoFilter)
                {
                    Caption = 'Lot No Filter';
                    ToolTip = 'Specifies the inventory filtered on Lot No.';
                    ApplicationArea = ShopFloorLogisticsAppArea12FDW;
                    TableRelation = "Lot No. Information"."Lot No.";

                    trigger OnValidate()
                    begin
                        SetColumns(MATRIX_SetWanted::Initial);
                    end;
                }

Var

        LotNoFilter: code[50];

Procedure

    local procedure UpdateMatrixSubform()
    begin
        CurrPage.MatrixForm.PAGE.Load(MATRIX_CaptionSet, MatrixRecords, TempMatrixLocation, MATRIX_CurrSetLength, LotNoFilter);
        CurrPage.MatrixForm.PAGE.SetRecord(Rec);
        CurrPage.Update(false);
    end;

On Page 9231 we need 2 modifications (or Events if possible) to make use of the Lot No. Filter set:

  • Show Inventory Filtered on Lot No Filter
  • Filter Item Lines that have Inventory on Lot No. Code
    trigger OnFindRecord(Which: Text): Boolean
    var
        Item: record Item;
    begin
        if Rec.Find(Which) then begin
            Item := Rec;
            while true do
                if IsItemInSelection() then
                    exit(true)
                else
                    if (Rec.Next(1) = 0) then BEGIN
                        Rec := Item;
                        if Rec.Find(Which) then
                            while true do
                                if IsItemInSelection() then
                                    exit(true)
                                else
                                    if (Rec.NEXT(-1) = 0) then
                                        exit(false);
                    END;
        end;
        exit(false);
    end;

    trigger OnNextRecord(Steps: Integer): Integer
    var
        Item: record Item;
        RealSteps: Integer;
        NextSteps: Integer;
    begin
        if (Steps = 0) then
            exit;

        Item := Rec;

        repeat
            NextSteps := Rec.Next(Steps / Abs(Steps));
            if IsItemInSelection() then begin
                RealSteps := RealSteps + NextSteps;
                Item := Rec;
            end;
        until (NextSteps = 0) or (RealSteps = Steps);
        Rec := Item;

        if not Rec.Find() then;
        exit(RealSteps);
    end;

    local procedure IsItemInSelection(): Boolean
    var
        Item: Record Item;
    begin
        if LotNoFilter <> '' then begin
            Item.Get("No.");
            item.SetFilter("Lot No. Filter", LotNoFilter);
            item.CalcFields(Inventory);
            exit(item.Inventory <> 0)
        end else
            exit(true);
    end;

Var

     LotNoFilter: Code[50];

Procedures

    local procedure MATRIX_OnAfterGetRecord(ColumnID: Integer)
    var
        TempItem: Record Item temporary;
    begin
        TempItem.Copy(Rec);
        TempItem.SetRange("Location Filter", MatrixRecords[ColumnID].Code);

        if LotNoFilter <> '' then
            TempItem.SetFilter("Lot No. Filter", LotNoFilter)
        else
            TempItem.SetRange("Lot No. Filter");

        TempItem.CalcFields(Inventory);
        MATRIX_CellData[ColumnID] := TempItem.Inventory;
        SetVisible();
    end;
local procedure MatrixOnDrillDown(ColumnID: Integer)
begin
    ItemLedgerEntry.SetCurrentKey(
      "Item No.", "Entry Type", "Variant Code", "Drop Shipment", "Location Code", "Posting Date");
    ItemLedgerEntry.SetRange("Item No.", "No.");

    if LotNoFilter <> '' then
        ItemLedgerEntry.SetFilter("Lot No.", LotNoFilter);

    ItemLedgerEntry.SetRange("Location Code", MatrixRecords[ColumnID].Code);
    PAGE.Run(0, ItemLedgerEntry);
end;
procedure Load(MatrixColumns1: array[32] of Text[1024]; var MatrixRecords1: array[32] of Record Location; var MatrixRecord1: Record Location; CurrSetLength: Integer; LotNoFilter1: Code[50])
begin
    MATRIX_CurrSetLength := CurrSetLength;
    CopyArray(MATRIX_ColumnCaption, MatrixColumns1, 1);
    CopyArray(MatrixRecords, MatrixRecords1, 1);
    TempMatrixLocation.Copy(MatrixRecord1, true);
    LotNoFilter := LotNoFilter1;
end;

hhout avatar Apr 16 '19 09:04 hhout

Conceptually Lot No is unique for an item (in general lot 1 for item A is different than lot 1 for item B) but the page in question is designed to work with multiple items. I'm closing this item for now, if you still have need for this please create new idea on https://aka.ms/bcideas and explain which business scenarios you need to address.

AlexanderYakunin avatar Jul 15 '20 07:07 AlexanderYakunin