diff --git a/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs b/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs index 4aab440fe..734e94fd0 100644 --- a/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs +++ b/dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs @@ -771,6 +771,7 @@ public short dfwnext() return GX_ASCDEL_WRITEERROR; } } + const int MAX_DECIMAL_PRECISION = 29; public short dfwpnum(decimal num, int dec) { if (_writeStatus == FileIOStatus.Closed) @@ -778,7 +779,7 @@ public short dfwpnum(decimal num, int dec) GXLogging.Error(log, "Error ADF0004"); return GX_ASCDEL_INVALIDSEQUENCE; } - appendFld(StringUtil.Str(num, 18, dec).TrimStart(null)); + appendFld(StringUtil.Str(num, MAX_DECIMAL_PRECISION, dec).TrimStart(null)); return GX_ASCDEL_SUCCESS; } public short dfwptxt(string s, int len) diff --git a/dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs b/dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs index f1e91875e..e616a541e 100644 --- a/dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs +++ b/dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs @@ -9,6 +9,20 @@ public class DfrgFunctions const string APPLICATIONS_CONTENT = "[ { \"Id\": \"4caaaed5-1160-4132-b54f-0191e527a84a\", \"Type\": 1, \"EnvironmentGUID\": \"b3730606-0f2a-4e8a-b395-d8fdf226def8\", \"IsNew\": false }]"; const string DOCUMENT_CONTENT = "Line 1Line 2Line 3"; const string MS923_CONTENT = "1234567890123"; + + [Fact] + public void dfwpnumTest() + { + GxContext context = new GxContext(); + string fileName = Path.Combine(BaseDir, "dfwpnumTest.txt"); + context.FileIOInstance.dfwopen(fileName, ",", "\"", 0, "UTF-8"); + context.FileIOInstance.dfwpnum(99999999999999999.5M, 5); + context.FileIOInstance.dfwnext(); + context.FileIOInstance.dfwclose(); + + string content = File.ReadAllText(fileName); + Assert.Contains("99999999999999999.5", content, StringComparison.OrdinalIgnoreCase); + } [Fact] public void dfrgtxtANSITest() {