SAP.NET Context: System Exception When Creating .NET Type Marshaling

My application sends a lot of data to SAP. To do this, he creates an SAP table object and sends it. I get this error somewhat regularly, but not reliably:

System exception thrown while marshaling .NET type 20081219 to RFCTYPE_BCD
   at SAP.Connector.Rfc.RfcMarshal.NetFieldToRfcField(Object src, RFCTYPE type, Encoding encoding, Byte[] dest, Int32 offset, Int32 len, Int32 charSize, Int32 decimals)
   at SAP.Connector.Rfc.RfcStructureUtil.ToRfcStructure(Object obj, Byte[] dest, Type t, Encoding encoding, Boolean isUnicode, PropertyInfo[] propinfos, RfcStructInfo structInfo)
   at SAP.Connector.Rfc.RfcStructureUtil.GetITabFromList(SAPConnection conn, Object list, Type t, RfcStructInfo structInfo, Int32 itab)
   at SAP.Connector.Rfc.RfcClient.PrepareClientParameters(Type classType, MethodInfo m, Boolean isTQRfc, Object[] MethodParamsIn, RFC_PARAMETER[]& paramsIn, RFC_PARAMETER[]& paramsOut, RFC_TABLE[]& tables, ParameterMap[]& paramMaps)
   at SAP.Connector.Rfc.RfcClient.RfcInvoke(SAPClient proxy, String method, Object[] methodParamsIn)
   at SAP.Connector.SAPClient.SAPInvoke(String method, Object[] methodParamsIn)

What is strange is that this does not happen every time. Also, the .NET type that he complains about, "20081219" is the data I pass in (date), not the type. I think the type of this field RFCTYPE.RFCTYPE_TIME.

Any suggestions for fixing this intermittent error? Is there some kind of state that I have to clear between calls in the SAP RFC?


Update:

As requested, here is the code that calls SAP:

Using sapConnection As New MySapProxy(ConnectionString)
  sapConnection.Connection.Open()
  sapConnection.TheSapRfcICall(SapOpCode, Nothing, Nothing, sapTable, ResultTable)
End Using

I think multiple threads are using the same connection. Using SAP.Connector.GetNewConnectioninstead has not changed anything.


Update:

, ! ?

, , ?


Update:

@ Igal Serban, , . () ! .


Update:

librfc32.dll 6403.3.78.4732.

+3
4

4: -, , librfc . , , . :

  • .
  • . ( ). . , . , - . , - () :

MySapProxy proxy = new MySapProxy(); // do this only once.

// and in you main loop:
using (proxy.Connection = Connection.GetConnection(connectionString))
{
    proxy.TheSapRfcICall(SapOpCode, Nothing, Nothing, sapTable, ResultTable)
}

. .

3:. librfc32.dll? system32 - % path%.

2: Sap - kb. , sdn.sap.com, .

1: SAP- 1000057 :

RfcMarshalException System.Xml.Xsl.XsltException .

. .

.

** 0: ** . . ? , ?

+1

Edit

, . , RFCTYPE_BCD (Business Connector Decimal), ( ?). - , . - ( - -, Business Connector):

VB ( sapTable):

Using sapConnection As New MySapProxy(ConnectionString)
  sapConnection.Connection.Open()
  try {
    sapConnection.TheSapRfcICall(SapOpCode, Nothing, Nothing, sapTable, ResultTable)
  } catch (Exception e) {
    StringBuilder sb = new StringBuilder();
    foreach (Field f in sapTable.Fields) {
      sb.AppendLine(f.Name + "=" f.Value);
    }
    sb.AppendLine(e.StackTrace);
    File.AppendAllText("C:\\Exception_" + DateTime.Now.ToString("u") + ".txt", sb.ToString());
  }
End Using

, , , , , .

========

, , , , , (20081219) ?

try/catch , SAP, ? , .

, - SAP SAP .

+1

, ( - ToString()) BCD (- ).

, , .

:

.

, ? , , , , . , SAP , ( ).

0

Could this be a date format? You say that this does not happen every time.
Therefore, when you pass 20081202, it takes “12” as the daily part and 02 as part of the month. This is normal.
But when you pass 20081219, it tries to parse 19 as a month and throws an exception?
Check it with your SAP administrator.

0
source

All Articles