From 84207c07825c8d93765b0fd0623ed91759241aa8 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Mon, 7 Sep 2026 18:32:25 +0530 Subject: [PATCH 1/8] Fix And automation --- .../Costing/PostInventoryCosttoGL.Report.al | 12 +-- .../SCM/SCMInventoryReportsI.Codeunit.al | 93 +++++++++++++++++-- 2 files changed, 90 insertions(+), 15 deletions(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index 05f443ccab6..c311e5faced 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -849,23 +849,21 @@ report 1002 "Post Inventory Cost to G/L" local procedure GetDimText(var DimSetEntry: Record "Dimension Set Entry") var - OldDimText: Text[250]; + OldDimText: Text; begin DimText := ''; if DimSetEntry.FindSet() then repeat - OldDimText := DimText; if DimText = '' then - DimText := StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") + OldDimText := StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") else - DimText := + OldDimText := StrSubstNo( '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); - if StrLen(DimText) > MaxStrLen(OldDimText) then begin - DimText := OldDimText; + if StrLen(OldDimText) > MaxStrLen(DimText) then exit; - end; + DimText := OldDimText; until DimSetEntry.Next() = 0; end; diff --git a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al index 9132caa215b..0c9b14a4ee9 100644 --- a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al +++ b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al @@ -10,26 +10,27 @@ codeunit 137301 "SCM Inventory Reports - I" var Assert: Codeunit Assert; + LibraryCosting: Codeunit "Library - Costing"; + LibraryDimension: Codeunit "Library - Dimension"; LibraryERM: Codeunit "Library - ERM"; - LibraryTestInitialize: Codeunit "Library - Test Initialize"; LibraryInventory: Codeunit "Library - Inventory"; - LibrarySales: Codeunit "Library - Sales"; - LibraryCosting: Codeunit "Library - Costing"; - LibraryPurchase: Codeunit "Library - Purchase"; LibraryManufacturing: Codeunit "Library - Manufacturing"; + LibraryPurchase: Codeunit "Library - Purchase"; + LibraryRandom: Codeunit "Library - Random"; LibraryReportDataset: Codeunit "Library - Report Dataset"; LibraryReportValidation: Codeunit "Library - Report Validation"; - LibraryVariableStorage: Codeunit "Library - Variable Storage"; + LibrarySales: Codeunit "Library - Sales"; LibrarySetupStorage: Codeunit "Library - Setup Storage"; + LibraryTestInitialize: Codeunit "Library - Test Initialize"; LibraryUtility: Codeunit "Library - Utility"; + LibraryVariableStorage: Codeunit "Library - Variable Storage"; LibraryWarehouse: Codeunit "Library - Warehouse"; - LibraryRandom: Codeunit "Library - Random"; isInitialized: Boolean; IncorrectValueInCellErr: Label 'Row count in report Inventory Validation before posting purchase order should be the same as after posting purchase order', Comment = '%1 - row % 2 - column'; - QuantityErr: Label 'Quantity Must Be %1 for %2 Document No. %3'; NothingToPostTxt: Label 'There is nothing to post to the general ledger.'; - ValueEntriesWerePostedTxt: Label 'value entries have been posted to the general ledger.'; + QuantityErr: Label 'Quantity Must Be %1 for %2 Document No. %3'; SetupBlockedErr: Label 'Setup is blocked in %1 for %2 %3 and %4 %5.', Comment = '%1 - General/Inventory Posting Setup, %2 %3 %4 %5 - posting groups.'; + ValueEntriesWerePostedTxt: Label 'value entries have been posted to the general ledger.'; [Test] [HandlerFunctions('InvtCostAndPriceListRepRequestPageHandler')] @@ -1551,6 +1552,39 @@ codeunit 137301 "SCM Inventory Reports - I" LibraryReportDataset.AssertCurrentRowValueEquals('SalesLCY', ItemJournalLine.Amount); end; + [Test] + [HandlerFunctions('PostInvtCostToGLRequestPageHandler')] + procedure PostInventoryCostToGLWithDimensionTextLongerThan250Characters() + var + Item: Record Item; + ItemJournalLine: Record "Item Journal Line"; + PostValueEntryToGL: Record "Post Value Entry to G/L"; + PostMethod: Option "per Posting Group","per Entry"; + DimensionSetID: Integer; + ExpectedDimText: Text; + begin + // [FEATURE] [AI test 0.4] + // [SCENARIO 649269] Post Inventory Cost to G/L does not fail when dimension text exceeds 250 characters. + Initialize(); + + // [GIVEN] A positive item adjustment with six 20-character dimension codes and values. + CreateItem(Item); + CreateMaxLengthDimensionSet(DimensionSetID, ExpectedDimText); + CreateAndPostItemJournalLineWithDimension(ItemJournalLine, ItemJournalLine."Entry Type"::"Positive Adjmt.", Item."No.", DimensionSetID); + + // [WHEN] Run the Post Inventory Cost to G/L report per posting group without posting. + Commit(); + LibraryVariableStorage.Enqueue(PostMethod::"per Posting Group"); + LibraryVariableStorage.Enqueue(Item."No."); + LibraryVariableStorage.Enqueue(false); + PostValueEntryToGL.SetRange("Item No.", Item."No."); + Report.Run(Report::"Post Inventory Cost to G/L", true, false, PostValueEntryToGL); + + // [THEN] The report contains the five complete pairs that fit and omits the sixth pair. + LibraryReportDataset.LoadDataSetFile(); + LibraryReportDataset.AssertElementWithValueExists('DimText', ExpectedDimText); + end; + local procedure Initialize() var LibraryERMCountryData: Codeunit "Library - ERM Country Data"; @@ -1943,6 +1977,49 @@ codeunit 137301 "SCM Inventory Reports - I" NoSeriesLine.Modify(true); end; + local procedure CreateMaxLengthDimensionSet(var DimensionSetID: Integer; var ExpectedDimText: Text) + var + Dimension: Record Dimension; + DimensionValue: Record "Dimension Value"; + DimensionCode: Code[20]; + DimensionValueCode: Code[20]; + i: Integer; + begin + for i := 1 to 6 do begin + DimensionCode := 'DIMENSIONS-CODE-000' + Format(i); + Dimension.Init(); + Dimension.Validate(Code, DimensionCode); + Dimension.Insert(true); + + DimensionValueCode := 'DIMENSIONS-VAL-0000' + Format(i); + LibraryDimension.CreateDimensionValueWithCode(DimensionValue, DimensionValueCode, DimensionCode); + DimensionSetID := LibraryDimension.CreateDimSet(DimensionSetID, DimensionCode, DimensionValueCode); + + if i <= 5 then + if ExpectedDimText = '' then + ExpectedDimText := StrSubstNo('%1 - %2', DimensionCode, DimensionValueCode) + else + ExpectedDimText += StrSubstNo('; %1 - %2', DimensionCode, DimensionValueCode); + end; + end; + + local procedure CreateAndPostItemJournalLineWithDimension(var ItemJournalLine: Record "Item Journal Line"; EntryType: Enum "Item Ledger Document Type"; ItemNo: Code[20]; DimensionSetID: Integer) + var + ItemJournalTemplate: Record "Item Journal Template"; + ItemJournalBatch: Record "Item Journal Batch"; + begin + LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate, ItemJournalTemplate.Type::Item); + LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch, ItemJournalBatch."Template Type"::Item, ItemJournalTemplate.Name); + LibraryInventory.CreateItemJournalLine( + ItemJournalLine, ItemJournalBatch."Journal Template Name", ItemJournalBatch.Name, + EntryType, ItemNo, LibraryRandom.RandDec(100, 2)); + ItemJournalLine.Validate("Unit Amount", LibraryRandom.RandDec(100, 2)); + if DimensionSetID <> 0 then + ItemJournalLine.Validate("Dimension Set ID", DimensionSetID); + ItemJournalLine.Modify(true); + LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name", ItemJournalBatch.Name); + end; + [MessageHandler] [Scope('OnPrem')] procedure MessageHandler(Message: Text[1024]) From 7062c8151b6c35aad9967c18a29d9110af32d100 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Tue, 8 Sep 2026 10:36:49 +0530 Subject: [PATCH 2/8] Change in automation --- .../BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index c311e5faced..28d21b5c8b4 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -849,7 +849,7 @@ report 1002 "Post Inventory Cost to G/L" local procedure GetDimText(var DimSetEntry: Record "Dimension Set Entry") var - OldDimText: Text; + OldDimText: Text[250]; begin DimText := ''; From e58eaf3a7449c7286d48547badb893ccfd2cc3b6 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Tue, 8 Sep 2026 12:22:04 +0530 Subject: [PATCH 3/8] Alexey Suggestion --- .../Inventory/Costing/PostInventoryCosttoGL.Report.al | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index 28d21b5c8b4..f02358f5c9b 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -856,11 +856,13 @@ report 1002 "Post Inventory Cost to G/L" if DimSetEntry.FindSet() then repeat if DimText = '' then - OldDimText := StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") + OldDimText := + CopyStr( + StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"), 1, MaxStrLen(DimText)) else OldDimText := - StrSubstNo( - '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); + CopyStr( + StrSubstNo('%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"), 1, MaxStrLen(DimText)); if StrLen(OldDimText) > MaxStrLen(DimText) then exit; DimText := OldDimText; From 7dffd0144f95496905b1086bd492015f2337df72 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Tue, 8 Sep 2026 18:51:27 +0530 Subject: [PATCH 4/8] Suggestion FIx --- .../Inventory/Costing/PostInventoryCosttoGL.Report.al | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index f02358f5c9b..27896d91790 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -857,15 +857,14 @@ report 1002 "Post Inventory Cost to G/L" repeat if DimText = '' then OldDimText := - CopyStr( - StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"), 1, MaxStrLen(DimText)) + StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") else OldDimText := - CopyStr( - StrSubstNo('%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"), 1, MaxStrLen(DimText)); + StrSubstNo('%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); + DimText := CopyStr(OldDimText, 1, MaxStrLen(DimText)); + if StrLen(OldDimText) > MaxStrLen(DimText) then exit; - DimText := OldDimText; until DimSetEntry.Next() = 0; end; From 4c7e8ec830d0aaf4c88f73c5d80fe55be297412f Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Wed, 9 Sep 2026 11:57:38 +0530 Subject: [PATCH 5/8] Suggestion --- .../Costing/PostInventoryCosttoGL.Report.al | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index 27896d91790..502c1088037 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -856,15 +856,16 @@ report 1002 "Post Inventory Cost to G/L" if DimSetEntry.FindSet() then repeat if DimText = '' then - OldDimText := - StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") + OldDimText := StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") else - OldDimText := - StrSubstNo('%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); + if StrLen(StrSubstNo( + '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code")) > MaxStrLen(DimText) then + exit; + + OldDimText := StrSubstNo( + '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); DimText := CopyStr(OldDimText, 1, MaxStrLen(DimText)); - if StrLen(OldDimText) > MaxStrLen(DimText) then - exit; until DimSetEntry.Next() = 0; end; From f3ea5f056e60e14c0c22a10656438ed86edc0b74 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Wed, 9 Sep 2026 13:40:22 +0530 Subject: [PATCH 6/8] Change in fix and autoamtion --- .../Costing/PostInventoryCosttoGL.Report.al | 12 ++++++------ .../W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index 502c1088037..46f24b6d423 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -858,12 +858,12 @@ report 1002 "Post Inventory Cost to G/L" if DimText = '' then OldDimText := StrSubstNo('%1 - %2', DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code") else - if StrLen(StrSubstNo( - '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code")) > MaxStrLen(DimText) then - exit; - - OldDimText := StrSubstNo( - '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); + if StrLen(StrSubstNo('%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code")) > MaxStrLen(DimText) then + exit + else + OldDimText := + StrSubstNo( + '%1; %2 - %3', DimText, DimSetEntry."Dimension Code", DimSetEntry."Dimension Value Code"); DimText := CopyStr(OldDimText, 1, MaxStrLen(DimText)); until DimSetEntry.Next() = 0; diff --git a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al index 0c9b14a4ee9..b273ee8191c 100644 --- a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al +++ b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al @@ -1561,7 +1561,7 @@ codeunit 137301 "SCM Inventory Reports - I" PostValueEntryToGL: Record "Post Value Entry to G/L"; PostMethod: Option "per Posting Group","per Entry"; DimensionSetID: Integer; - ExpectedDimText: Text; + ExpectedDimText: Text[250]; begin // [FEATURE] [AI test 0.4] // [SCENARIO 649269] Post Inventory Cost to G/L does not fail when dimension text exceeds 250 characters. @@ -1977,7 +1977,7 @@ codeunit 137301 "SCM Inventory Reports - I" NoSeriesLine.Modify(true); end; - local procedure CreateMaxLengthDimensionSet(var DimensionSetID: Integer; var ExpectedDimText: Text) + local procedure CreateMaxLengthDimensionSet(var DimensionSetID: Integer; var ExpectedDimText: Text[250]) var Dimension: Record Dimension; DimensionValue: Record "Dimension Value"; From 7bb2cd923e19eaff83d94928f46f920ed4fde7a7 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Wed, 9 Sep 2026 15:48:52 +0530 Subject: [PATCH 7/8] Warning Remove --- src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al index b273ee8191c..0c9b14a4ee9 100644 --- a/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al +++ b/src/Layers/W1/Tests/SCM/SCMInventoryReportsI.Codeunit.al @@ -1561,7 +1561,7 @@ codeunit 137301 "SCM Inventory Reports - I" PostValueEntryToGL: Record "Post Value Entry to G/L"; PostMethod: Option "per Posting Group","per Entry"; DimensionSetID: Integer; - ExpectedDimText: Text[250]; + ExpectedDimText: Text; begin // [FEATURE] [AI test 0.4] // [SCENARIO 649269] Post Inventory Cost to G/L does not fail when dimension text exceeds 250 characters. @@ -1977,7 +1977,7 @@ codeunit 137301 "SCM Inventory Reports - I" NoSeriesLine.Modify(true); end; - local procedure CreateMaxLengthDimensionSet(var DimensionSetID: Integer; var ExpectedDimText: Text[250]) + local procedure CreateMaxLengthDimensionSet(var DimensionSetID: Integer; var ExpectedDimText: Text) var Dimension: Record Dimension; DimensionValue: Record "Dimension Value"; From 0dc54a9c95837cd94ca03ad33f93d7245b802d39 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Wed, 9 Sep 2026 19:23:49 +0530 Subject: [PATCH 8/8] Length Removed --- .../BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al index 46f24b6d423..4e6554c6f7e 100644 --- a/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al +++ b/src/Layers/W1/BaseApp/Inventory/Costing/PostInventoryCosttoGL.Report.al @@ -849,7 +849,7 @@ report 1002 "Post Inventory Cost to G/L" local procedure GetDimText(var DimSetEntry: Record "Dimension Set Entry") var - OldDimText: Text[250]; + OldDimText: Text; begin DimText := '';