Skip to Content

Culture-specific type conversion in .NET Connector

Hi everybody,

I think there is a bug in .NET Connector and here is how to reproduce it:

- Create function module with optional input parameter of type FLTP and default value '12345.67890' with comma as decimal separator (note that the value is surrounded with single quotation marks, otherwise the function module would not be activated.

- Make the function module accessible via RFC, enable support of basXML.

- Set decimal separator symbol as comma in regional options of your Windows system.

- Call the functional module using .NET Connector.

Expected behavior: the parameter would get its default value of 12345.6789

Actual behavior: the parameter gets value of 0

The reason is: the default value is explicitly applied to the parameter in the code of .NET Connector and current thread culture is used for conversion from the default string value to the default double value.

If I set the decimal separator symbol as point in settings of my Windows system, the parameter gets its default value as expected.

Here is the call stack:

mscorlib.dll!System.Number.ParseDouble(string value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) Unknown

sapnco.dll!SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(string value, ref object currentValue) Unknown

sapnco.dll!SAP.Middleware.Connector.RfcParameter.SetDefaultValue() Unknown

sapnco.dll!SAP.Middleware.Connector.RfcFunction.RfcFunction(SAP.Middleware.Connector.RfcFunctionMetadata metadata) Unknown

sapnco.dll!SAP.Middleware.Connector.RfcFunctionMetadata.CreateFunction() Unknown

sapnco.dll!SAP.Middleware.Connector.RfcRepository.CreateFunction(string name) Unknown

Exception in ParseDouble():

System.FormatException occurred

HResult=-2146233033

Message=Input string was not in a correct format.

Source=mscorlib

StackTrace:

at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)

InnerException:

And then:

sapnco.dll!SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(string value, ref object currentValue) Unknown

sapnco.dll!SAP.Middleware.Connector.RfcParameter.SetDefaultValue() Unknown

sapnco.dll!SAP.Middleware.Connector.RfcFunction.RfcFunction(SAP.Middleware.Connector.RfcFunctionMetadata metadata) Unknown

sapnco.dll!SAP.Middleware.Connector.RfcFunctionMetadata.CreateFunction() Unknown

sapnco.dll!SAP.Middleware.Connector.RfcRepository.CreateFunction(string name) Unknown

Exception in ConvertString():

SAP.Middleware.Connector.RfcTypeConversionException occurred

HResult=-2146232832

Message=Cannot convert "12345.67890" into FLOAT

Source=sapnco

StackTrace:

at SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(String value, Object& currentValue)

InnerException:

HResult=-2146233033

Message=Input string was not in a correct format.

Source=mscorlib

StackTrace:

at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)

at SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(String value, Object& currentValue)

InnerException:

Disassembled code of SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString():

internal override void ConvertString(string value, ref object currentValue)

{

try

{

double num = double.Parse(value);

if (num == 0.0)

currentValue = (object) null;

else

currentValue = (object) num;

}

catch (Exception ex)

{

throw new RfcTypeConversionException("Cannot convert " + RfcUtilities.StringToLiteral(value) + " into FLOAT", ex);

}

}

More info:

**** Log file opened by process 14276 at 2016-06-01 14:24:50 (UTC+02:00 W. Europe Summer Time)

SAP .NET Connector 3.0 with file version 3.0.16.0 running on 32-bit .NET Framework 4.0.30319.42000

Program: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\te.processhost.managed.exe

Working directory: D:\xxx\Out

Operating system: 64-bit

Processor: 8x AMD64 (or x64)

SAP release: 721, Kernel release: 721, Kernel patch level: 527

Hostname: xxx, IP address: xxx.xxx.xxx.xxx, IP_v6 address:

Default trace level: None

>> Error entry 2016-06-01 14:24:50.568 [Thread 6]

SAP.Middleware.Connector.RfcTypeConversionException: Cannot convert "12345.67890" into FLOAT ---> System.FormatException: Input string was not in a correct format.

at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)

at SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(String value, Object& currentValue)

--- End of inner exception stack trace ---

at SAP.Middleware.Connector.RfcScalarMetadataFloat.ConvertString(String value, Object& currentValue)

at SAP.Middleware.Connector.RfcParameter.SetDefaultValue()

Regards,

Michael

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jun 06, 2016 at 08:26 AM

    Hi Michael,

    this is indeed a bug and needs to be fixed.

    Best regards,

    Markus

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.