Skip to content

Commit

Permalink
Update samples and Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaia committed Mar 24, 2020
1 parent 3b60195 commit 89ad420
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 190 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
61 changes: 35 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,24 @@ Map RFC mapameters to class
Open a connection to server and invoke a BAPI

```C#
using (var conn = new RfcConnection(userName, password, hostname, client))
using (var conn = new RfcConnection(builder => builder
.UseConnectionHost("hostname")
.UseLogonUserName("user")
.UseLogonPassword("password)
.UseLogonClient("cln")))
{
conn.Open();
using(var func = _conn.CallRfcFunction("BAPI_COMPANYCODE_GETLIST"))
{
func.Invoke();
}
}
```

or

```C#
using (var conn = new RfcConnection("Server=server_name;lang=en;user=testUser;pwd=secret"))
{
conn.Open();
using(var func = _conn.CallRfcFunction("BAPI_COMPANYCODE_GETLIST"))
Expand Down Expand Up @@ -100,28 +117,20 @@ Included samples in project
* 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.

```C#
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.

```C#
public string SncQop { get ; set; }

public string SncMyname { get; set; }

public string SncPartnername { get; set; }

public string SncLib { get; set; }
```
## Connection String

Example : Server=server_name;lang=en;user=testUser;pwd=secret

| Value | Alias |
| ----------------- | ----------------------------------------------------------------------|
| User Name | "userName", "userId", "uid", "user", "u" |
| password | "password", "passwd", "pass", "pwd", "p" |
| Host | "target_host", "targetHost", "host", "server", "h" |
| Logon Language | "language", "lang", "l" |
| System Client | "client", "cl", "c" |
| SystemNumber | "system_number", "systemnumber", "sysnr" |
| SystemId | "system_id", "systemid", "sysid" |
| Trace | "trace", "tr", "RfcSdkTrace" |
| Snc Mode | "snc_mode", "sncmode", "UseSnc", "snc" |
| Snc Qop | "snc_partnername", "sncpartnername", "snc_partner", "sncpartner" |
| Snc Lib | "snc_library", "snc_lib", "snclib" |
2 changes: 1 addition & 1 deletion samples/BapiCompanyList/BapiCompanyList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/BapiCustomerDetail/BapiCustomerDetail.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions samples/BapiCustomerList/BapiCustomerList.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>Sample.BapiCustomerList</AssemblyName>
<RootNamespace>Sample.BapiCustomerList</RootNamespace>
<Authors>Nuno Maia</Authors>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
</ItemGroup>

<ItemGroup>
Expand Down
57 changes: 20 additions & 37 deletions samples/BapiCustomerList/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@ namespace Sample.BapiCustomerList
{
class Options
{
[Option('u', "username", Required = true, HelpText = "RFC User Name")]
public string UserName { get; set; }

[Option('p', "password", Required = true, HelpText = "RFC User Password")]
public string Password { get; set; }

[Option('h', "hostname", Required = true, HelpText = "RFC Server Hostname")]
public string Hostname { get; set; }

[Option('c', "client", Required = true, HelpText = "RFC Server Client Id")]
public string Client { get; set; }
[Option('c', "connection", Required = true, HelpText = "Connection String")]
public string Connection { get; set; }
}

class Program
Expand Down Expand Up @@ -90,35 +81,27 @@ static void Main(string[] args)
var version = RfcConnection.GetLibVersion();
Console.WriteLine($"currently loaded sapnwrfc library version : Major {version.MajorVersion}, Minor {version.MinorVersion}, patchLevel {version.PatchLevel}");

using (var conn = new RfcConnection(builder => builder
.UseConnectionHost(o.Hostname)
.UseLogonUserName(o.UserName)
.UseLogonPassword(o.Password)
.UseLogonClient(o.Client)))
using var conn = new RfcConnection(o.Connection);
conn.Open();
using var func = conn.CallRfcFunction("BAPI_CUSTOMER_GETLIST");
var inParams = new ListCustomersInputParameters
{
conn.Open();
using (var func = conn.CallRfcFunction("BAPI_CUSTOMER_GETLIST"))
{
var inParams = new ListCustomersInputParameters
{
MaxRows = 10,
Range = new IdRange[]
{
MaxRows = 10,
Range = new IdRange[]
{
new IdRange() { Sign = "I", Option = "BT", High = "ZZZZZZZZZZ" }
}
};

func.Invoke(inParams);
var returnValue = func.GetOutputParameters<ListCustomersOutputParameters>();

Console.WriteLine(String.Format("|{0,-20}|{1,-10}", "Customer Number", "Customer Name"));
foreach (var row in returnValue.Addresses)
{
Console.WriteLine(String.Format("|{0,-20}|{1,-10}", row.CustomerId, row.Name));
}
}
}
};

func.Invoke(inParams);
var returnValue = func.GetOutputParameters<ListCustomersOutputParameters>();

Console.WriteLine(String.Format("|{0,-20}|{1,-10}", "Customer Number", "Customer Name"));
foreach (var row in returnValue.Addresses)
{
Console.WriteLine(String.Format("|{0,-20}|{1,-10}", row.CustomerId, row.Name));
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/RfcConnections/RfcConnections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/RfcReadTable/RfcReadTable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.6.0" />
<PackageReference Include="CommandLineParser" Version="2.7.82" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/NwRfcNet/NwRfcNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>NwRfcNet</AssemblyName>
<RootNamespace>NwRfcNet</RootNamespace>
<Version>0.6.0</Version>
<Version>0.7.0</Version>
<Authors>Nuno Maia</Authors>
<Description>An easy way of making SAP RFC calls from .NET Core (Windows, Linux and macOS )</Description>
<PackageTags>sap rfc bapi</PackageTags>
Expand All @@ -13,8 +13,8 @@
<DelaySign>false</DelaySign>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/nunomaia/NwRfcNet/</PackageProjectUrl>
<AssemblyVersion>0.6.0.0</AssemblyVersion>
<FileVersion>0.6.0.0</FileVersion>
<AssemblyVersion>0.7.0.0</AssemblyVersion>
<FileVersion>0.7.0.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Loading

0 comments on commit 89ad420

Please sign in to comment.