cancel
Showing results for 
Search instead for 
Did you mean: 

Culture-specific type conversion in .NET Connector

0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

siv_anan98
Discoverer
0 Kudos

Hi I'm using sapnco( 3.0.24.0) and sapnco_utils.dll(File versionL 3.0.24.0 and Product version: 3.0.0.42)

I'm getting error message while calling BAPI : BAPI_USER_GET_DETAIL And SUSR_GET_ADMIN_USER_LOGIN_INFO

source=sapnco stacktrace= at SAP.Middleware.Connector.RFCScalarMetaDataDate.ConvertString Cannot convert string into Date

Please help.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Michael,

this is indeed a bug and needs to be fixed.

Best regards,

Markus

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Michael,

please download NCo 3.0.18, which is containing a fix for this issue.

Best regards,

Markus