6

The SAP .NET Connector is not compatible with the .NET Core framework. Is there any other way to retrieve data from SAP when using .NET Core?

I've already searched for an alternative in the nuget package manager but I did not found one. Is there any workaround I can use?

I would very much like to benefit from the performance of .NET Core but I also need to be able to connect to SAP.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Dries
  • 113
  • 2
  • 2
  • 6
  • As a workaround, you can create your own nuget package containing the Sap.Data.Hana.v4.5.dll file, as hinted at here: https://stackoverflow.com/questions/41498542/net-connector-for-sap-hana-with-net-core Dotnet Build will complain about the framework mismatch, but it will work (at least on Windows). – Daz Jun 27 '18 at 10:50

4 Answers4

3

For making calls from a .NET Core or .NET Framework application, I've open-sourced a cross-platform library SapNwRfc.

Get it on NuGet:

dotnet add package SapNwRfc

or

PM> Install-Package SapNwRfc

Strengths:

  • Cross-platform: Windows / Linux / macOS
  • Maps input and output models by convention (zero configuration)
  • Mapping functions are generated on-the-fly using expression trees
  • Connection pooling with retry support, DI friendly
  • Allows test driven development by the means of simple mockable interfaces
  • Licensed under MIT

The library is fully unit-tested and production ready.

Example

string connectionString = "AppServerHost=MY_SERVER_HOST; SystemNumber=00; User=MY_SAP_USER; Password=SECRET; Client=100; Language=EN; PoolSize=5; Trace=8";

using var connection = new SapConnection(connectionString);
connection.Connect();

class SomeFunctionParameters
{
    [SapName("SOME_FIELD")]
    public string SomeField { get; set; }
}

using var someFunction = connection.CreateFunction("BAPI_SOME_FUNCTION_NAME");
someFunction.Invoke(new SomeFunctionParameters
{
    SomeField = "Some value",
});

For more details, see the README.

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
1

​I have created a library to easly making SAP RFC calls from .NET CORE Libray is supported in Windows, Linux and macOS. Check it solves your needs https://github.com/nunomaia/NwRfcNet/

Nuno Maia
  • 11
  • 1
0

I accept that you have an SOAP based Service on SAP side and you try to connect this SAP service via .NetCore. If this senerio is true, unfortunetelly you can not connect SOAP service with .NetCore via "Add Service Reference." But you can search about ".NetCore Wcf Client Service".

Another solution is that use Rest Service and simulate SOAP protocol.

Here is the sample problem and solution at there.

Client to send SOAP request and received response

Eyup Can ARSLAN
  • 692
  • 9
  • 25
  • Actually I make use of nuget package https://www.nuget.org/packages/sapnco3.x64/ in my projects(.net Framework 4.5). Now I've created a test application in .NET Core and it seems I cannot use the package cause it is not compatible with .NET core. I am wondering if there is any other nuget package I can use to connect to SAP (via RFC, not via SOAP) ... – Dries Apr 04 '18 at 13:37
-1

Besides the great work of huysentruitw, I would also like to mention our library:

dbosoft YaNco (Yet another .NET connector): https://github.com/dbosoft/YaNco


Highlights:

  • cross platform
  • DI / Unit testing friendly
  • based on functional programming (using Language.Ext)
  • ABAP callbacks support
  • commercial support / consulting services available from dbosoft.eu

License: MIT

.NET Versions: .NET 4.7.1 and higher, .NET Core 2.0 and higher, NET 5.0

Supported platforms: Windows, Linux and MacOS

Nuget: Dbosoft.YaNco


Instead of mapping from / to POCOs YaNco uses functions to map input/output of SAP RFC RFMs. This gives you a lot of flexibility in how you can map your data.

Example:

       await context.CallFunction("BAPI_COMPANYCODE_GETLIST",
                Output: f => f
                    .MapTable("COMPANYCODE_LIST", s =>
                        from code in s.GetField<string>("COMP_CODE")
                        from name in s.GetField<string>("COMP_NAME")
                        select (code, name)))
            .Match(
                r =>
                {
                    foreach (var (code, name) in r)
                    {
                        Console.WriteLine($"{code}\t{name}");
                    }
                },
                l => Console.WriteLine($"Error: {l.Message}"));