Question

I have an old program pushing some data from a Microsoft SQL server database to SAP. It uses Microsoft .NET Data Provider for mySAP Business Suite to connect to SAP and up to the moment it has worked perfectly.

Now, as a part of an improvement plan, I've been ask to migrate from Microsoft driver to the new SAP .Net Connector, version 3.0. Since I didn’t have any experience with either Microsoft connector neither with SAP connector, I started from the documentation. Even though I think I’ve done my homework I’m getting an error that I’m not able to solve or find any information about.

My main function:

    log.Debug("Get the SAP destination")
    Dim destination As RfcDestination = RfcDestinationManager.GetDestination("SAP")

    log.Debug("Fetch the function metadata")
    Dim rfcFunction As IRfcFunction = destination.Repository.CreateFunction("Z_TEC_CAT")

    log.Debug("Set the import parameters")
    Dim am As RfcStructureMetadata = destination.Repository.GetStructureMetadata("ZTEC_CAT")
    Dim exportTable As IRfcTable = rfcFunction.GetTable("ZTEC_CAT")
    FillIrfTable(exportTable, invoices)

    log.Debug("Invoking the function Z_TEC_CAT")
    rfcFunction.Invoke(destination)


A helper to populate the table that I have to send to SAP:

    Private Sub FillIrfTable(ByVal sapTable As IRfcTable, ByVal dt As DataTable)

    log.Debug("Started FillIrfTable")
    For Each row As DataRow In dt.Rows
        sapTable.Append()
        Dim index As Integer = 0
        Do While (index < dt.Columns.Count)
            Dim columName As String = dt.Columns.Item(index).ColumnName
            Dim columnValue = row.Item(index)
            sapTable.SetValue(columName, columnValue)
            index = (index + 1)
        Loop
    Next

    log.Debug("Completed FillIrfTable")

End Sub


When the exportable variable is empty, I get a NO_DATA exception and everything is fine, but when the table has records, it throws:

Failed calling SAP Function Module Z_TEC_CAT
SAP.Middleware.Connector.RfcAbapException: BDC_OPEN_ERROR
   at SAP.Middleware.Connector.RfcConnection.ThrowRfcErrorMsg()
   at SAP.Middleware.Connector.RfcConnection.RfcReceive(RfcFunction function)
   at SAP.Middleware.Connector.RfcFunction.RfcDeserialize(RfcConnection conn, IRfcIOStream stream)
   at SAP.Middleware.Connector.RfcFunction.RfcCallReceive(RfcConnection conn, IRfcIOStream stream, RFCID rid)
   at SAP.Middleware.Connector.RfcFunction.RfcCallReceive(RfcConnection conn)
   at SAP.Middleware.Connector.RfcFunction.Invoke(RfcDestination destination)


Does anyone know what can be happening? Any suggestion will be greatly appreciated.

Thank you,

Jan

Was it helpful?

Solution

After a week of fighting agains this I've found out what was going on and I think that publishing it may help others not to spend a lot of time on it.

It looks like the SAP Connector inserts a space in the call (Microsoft connector doesn't), and because of that, the SAP system couldn't map the parameter(the exportTable) I was sending to it and failed.

The SAP programmer on the other end has modified the function so now it is aware of the space and everything works fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top