Skip to content
An easy way of making SAP RFC calls from .NET Core
C#
Branch: master
Clone or download
Latest commit 17d1804 Jan 8, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets initial release Sep 17, 2019
samples closes #31 closes #5 Oct 4, 2019
src/NwRfcNet pass the right parameters for all types and add null checks for prope… Dec 20, 2019
tests/NwRfcNet.Tests closes #6 Sep 21, 2019
.gitattributes initial release Sep 17, 2019
.gitignore closes #31 closes #5 Oct 4, 2019
LICENSE Initial commit Sep 16, 2019
NwRfcNet.sln closes #31 closes #5 Oct 4, 2019
README.md Update README.md Jan 4, 2020

README.md

.NET client library for SAP NetWeaver RFC

An easy way of making SAP RFC calls from .NET. Libray is supported in Windows, Linux and macOS.

Supported Platforms & Prerequisites

  • Requires .NET Framework ( .NET Standard 2.0 or higher )

    • .NET Framework 4.6.1 or higher
    • .NET Core 2.0 or higher
  • OS versions

    • Windows x64.
    • Redhat Linux 7 or other Linux distribution that is supported simultaneously by .NET Core and SAP NetWeaver RFC.
    • macOS 10.12+.
  • SAP NetWeaver RFC Library 7.50 SDK C++ binaries must be installed locally. For download and installation instructions check SAP Note 2573790

Using this package

Add the package using the dotnet cli:

$ dotnet add package NwRfcNet

Create a class to match SAP RFC parameters

    public class BapiCompanyOutputParameters
    {
        public CompanyDetails[] Details { get; set; }
    }

    public class CompanyDetails
    {
        public string CompanyCode { get; set; }

        public string Name { get; set; }
    }

Map RFC mapameters to class

    RfcMapper mapper = new RfcMapper();

    mapper.Parameter<BapiCompanyOutputParameters>().Property(x => x.Details)
        .HasParameterName("COMPANYCODE_LIST")
        .HasParameterType(RfcFieldType.Table);

    mapper.Parameter<CompanyDetails>().Property(x => x.CompanyCode)
        .HasParameterName("COMP_CODE")
        .MaxLength(4)
        .HasParameterType(RfcFieldType.Char);

    mapper.Parameter<CompanyDetails>().Property(x => x.Name)
        .HasParameterName("COMP_NAME")
        .MaxLength(25)
        .HasParameterType(RfcFieldType.Char);

Open a connection to server and invoke a BAPI

    using (var conn = new RfcConnection(userName, password, hostname, client))
    {
        conn.Open();
        using(var func = _conn.CallRfcFunction("BAPI_COMPANYCODE_GETLIST"))
        {
            func.Invoke();
        }
    }

Get result and display to Console

    var returnValue =  func.GetOutputParameters<BapiCompanyOutputParameters>();
    Console.WriteLine(String.Format("|{0,-20}|{1,-10}", "Company Code", "Company Name"));
    foreach (var row in returnValue.Details)
    {
        Console.WriteLine(String.Format("|{0,-20}|{1,-10}", row.CompanyCode, row.Name));
    }

Output should be

Company Code Company Name
C001 company 1
C002 Company 2

Samples

Included samples in project

  • List FI Companies
  • List FI Customers
  • Get Details of a FI Customer
  • FI General Ledger Account
  • RFC Read Table

Single sign-on (SSO)

Alternatively it's possible to sign-on with SSO instead of user and password.

Example : Opening a RFC connection using NTLM.

    var conn = new RfcConnection(
        hostname: "server_name", 
        client: "000", 
        sncPartnername: @"p:DOMAIN\SRVACC",
        sncLib: @"gx64ntlm.dll" )

Define the SNC parameters related to your environment. If SncLib is not defined, NetWeaver RFC Library uses library defined in environment variable SNC_LIB or SNC_LIB_64.

        public string SncQop { get ; set; }

        public string SncMyname { get; set; }

        public string SncPartnername { get; set; }

        public string SncLib { get; set; }
You can’t perform that action at this time.