Skip to content

Commit 4fed1b5

Browse files
committed
v0.1.0
1 parent d5c3c95 commit 4fed1b5

File tree

10 files changed

+467
-371
lines changed

10 files changed

+467
-371
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424

2525
# RFC traces
2626
*.trc
27+
*.log
2728

2829
# sapnwrfc.ini example
29-
gorfc/sapnwrfc.ini
30+
# gorfc/sapnwrfc.ini
3031

3132
# Packages
3233
GoRFC/pkg/
@@ -44,3 +45,7 @@ Thumbs.db
4445
*.iml
4546
.idea
4647

48+
### VSCode
49+
.vscode
50+
*.code-workspace
51+

CHANGES

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CHANGES
2+
=======
3+
4+
0.0.1 (2016-02-01)
5+
------------------
6+
- Initial release
7+
8+
0.1.0 (2020-05-04)
9+
------------------
10+
- Darwin support
11+
- New connection parameters added, type changed to map
12+
- New connection attributes added, type changed to map
13+
- Table parameter accepts also array of variables
14+
- ABAP datatypes conversions fixed:
15+
- Bytes: RFCTYPE_BYTE, RFCTYPE_XSTRING
16+
- BCD: RFCTYPE_BCD
17+
- ABAP INT8 type added: RFCTYPE_INT8

README.md

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,66 @@
1-
# SAP NW RFC Connector for [Go](https://golang.org)
1+
[SAP NetWeawer RFC SDK](https://support.sap.com/en/product/connectors/nwrfcsdk.html) client bindings for GO.
22

3-
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/SAP/gorfc/gorfc)
4-
[![Go Report Card](https://goreportcard.com/badge/github.com/SAP/gorfc)](https://goreportcard.com/report/github.com/SAP/gorfc)
5-
[![license](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/SAP/gorfc/blob/master/LICENSE)
3+
[![license](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/SAP/gorfc/blob/master/LICENSE)
4+
[![Go Report Card](https://goreportcard.com/badge/github.com/SAP/gorfc)](https://goreportcard.com/report/github.com/SAP/gorfc)
5+
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/SAP/gorfc/gorfc)
66

7-
The *gorfc* package provides bindings for *SAP NW RFC Library*, for a comfortable way of calling remote enabled ABAP function modules (RFMs) from [Go](https://golang.org).
7+
## Features
88

9-
The current release is fully functional on Linux and experimental on Windows and macOS see the [Issue #1](https://github.com/SAP/gorfc/issues/1).
9+
- Stateless and stateful connections (multiple function calls in the same ABAP session / same context)
10+
- Automatic conversion between GO and ABAP datatypes
1011

11-
## Table of contents
12+
## Supported Platforms
1213

13-
* [Platforms and Prerequisites](#platforms-and-prerequisites)
14-
* [Install](#install)
15-
* [GO](#install-and-configure-go)
16-
* [SAP NW RFC Library](#install-sap-nw-rfc-library)
17-
* [gorfc](#install-gorfc)
18-
* [Getting Started](#getting-started)
19-
* [To Do](#to-do)
20-
* [References](#references)
14+
- Windows 10, macOS, Linux
2115

22-
## Platforms and Prerequisites
16+
## Prerequisites
2317

24-
The SAP NW RFC Library is a prerequisite for using the Go RFC connector and must be installed on the same system. It is available on many platforms supported by Go, except Plan 9 and BSD.
18+
### All platforms
2519

26-
A prerequisite to download *SAP NW RFC Library* is having a **customer or partner account** on *SAP Service Marketplace* . If you are SAP employee please check SAP OSS note [1037575 - Software download authorizations for SAP employees](http://service.sap.com/sap/support/notes/1037575).
20+
- GOLANG [requirements](https://golang.org/doc/install#requirements)
2721

28-
The _SAP NW RFC Library_ is fully backwards compatible, supporting all NetWeaver systems, from today, down to release R/3 4.0. You can and should always use the newest version released on Service Marketplace and connect to older systems as well.
22+
- SAP NWRFC SDK 7.50 PL3 or later must be [downloaded](https://launchpad.support.sap.com/#/softwarecenter/template/products/_APP=00200682500000001943&_EVENT=DISPHIER&HEADER=Y&FUNCTIONBAR=N&EVENT=TREE&NE=NAVIGATE&ENR=01200314690100002214&V=MAINT) (SAP partner or customer account required) and [locally installed](http://sap.github.io/node-rfc/install.html#sap-nw-rfc-library-installation)
23+
24+
- Using the latest version is recommended as SAP NWRFC SDK is fully backwards compatible, supporting all NetWeaver systems, from today S4, down to R/3 release 4.6C.
25+
- SAP NWRFC SDK [overview](https://support.sap.com/en/product/connectors/nwrfcsdk.html) and [release notes](https://launchpad.support.sap.com/#/softwarecenter/object/0020000000340702020)
26+
27+
- Build from source on macOS and older Linux systems, may require `uchar.h` file, attached to [SAP OSS Note 2573953](https://launchpad.support.sap.com/#/notes/2573953), to be copied to SAP NWRFC SDK include directory: [documentation](http://sap.github.io/PyRFC/install.html#macos)
28+
29+
### Windows
30+
31+
- [Visual C++ Redistributable Package for Visual Studio 2013](https://www.microsoft.com/en-US/download/details.aspx?id=40784) is required for runtime, see [SAP Note 2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50](https://launchpad.support.sap.com/#/notes/2573790)
32+
33+
- Build toolchain requires GCC and [MinGW](http://mingw-w64.org). Using TDM_GCC may lead to issues: https://stackoverflow.com/questions/35004744/golang-oci8-error-adding-symbols-file-in-wrong-format
34+
35+
### macOS
36+
37+
- Build toolchain requires GCC and Xcode Command Line Tools:
38+
39+
```shell
40+
$ xcode-select --install
41+
```
42+
43+
- The macOS firewall stealth mode must be disabled ([Can't ping a machine - why?](https://discussions.apple.com/thread/2554739)):
44+
45+
```shell
46+
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
47+
```
48+
49+
- Remote paths must be set in SAP NWRFC SDK for macOS: [documentation](http://sap.github.io/PyRFC/install.html#macos)
50+
51+
- Build from source requires `uchar.h` file, attached to [SAP OSS Note 2573953](https://launchpad.support.sap.com/#/notes/2573953), to be copied to SAP NWRFC SDK include directory: [documentation](http://sap.github.io/PyRFC/install.html#macos)
52+
53+
- Optionally: [valgrind](https://stackoverflow.com/questions/58360093/how-to-install-valgrind-on-macos-catalina-10-15-with-homebrew)
54+
55+
## SPJ articles
56+
57+
Highly recommended reading about RFC communication and SAP NW RFC Library, published in the SAP Professional Journal (SPJ)
58+
59+
- [Part I RFC Client Programming](https://wiki.scn.sap.com/wiki/x/zz27Gg)
60+
61+
- [Part II RFC Server Programming](https://wiki.scn.sap.com/wiki/x/9z27Gg)
62+
63+
- [Part III Advanced Topics](https://wiki.scn.sap.com/wiki/x/FD67Gg)
2964

3065
## Install
3166

@@ -119,7 +154,7 @@ func abapSystem() gorfc.ConnectionParameter {
119154
Ashost: "11.111.11.111",
120155
Sysnr: "00",
121156
Saprouter: "/H/222.22.222.22/S/2222/W/xxxxx/H/222.22.222.222/H/",
122-
}
157+
}
123158
}
124159

125160
func main() {
@@ -141,7 +176,7 @@ func main() {
141176
"RFCDATA1": "HELLÖ SÄP",
142177
"RFCDATA2": "DATA222",
143178
},
144-
}
179+
}
145180
r, _ := c.Call("STFC_STRUCTURE", params)
146181

147182
assert.NotNil(t, r["ECHOSTRUCT"])
@@ -154,7 +189,7 @@ func main() {
154189
assert.Equal(t, importStruct["RFCINT1"], echoStruct["RFCINT1"])
155190
assert.Equal(t, importStruct["RFCINT2"], echoStruct["RFCINT2"])
156191
assert.Equal(t, importStruct["RFCINT4"], echoStruct["RFCINT4"])
157-
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
192+
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
158193
assert.Equal(t, importStruct["RFCTIME"].(time.Time).Format("150405"), echoStruct["RFCTIME"].(time.Time).Format("15.
159194
assert.Equal(t, importStruct["RFCDATE"].(time.Time).Format("20060102"), e/Users/d037732/Downloads/gorfc/README.mdchoStruct["RFCDATE"].(time.Time).Format(".
160195
assert.Equal(t, importStruct["RFCDATA1"], echoStruct["RFCDATA1"])
@@ -166,15 +201,10 @@ func main() {
166201
c.Close()
167202
```
168203
169-
## To Do
170-
171-
* Improve the documentation
172-
* Fix Windows compiler flags
173-
174204
## References
175205
176-
* <a name="ref1"></a>[GO Installation](https://golang.org/doc/install)
177-
* <a name="ref2"></a>[GO Configuration](https://golang.org/doc/code.html)
178-
* <a name="ref3"></a>[GO Environment Variables](https://golang.org/cmd/go/#hdr-Environment_variables)
179-
* <a name="ref4"></a>[GO on Windows Example](http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/)
180-
* <a name="ref5"></a>[Another GO on Windows Example](https://github.com/abourget/getting-started-with-golang/blob/master/Getting_Started_for_Windows.md)
206+
- <a name="ref1"></a>[GO Installation](https://golang.org/doc/install)
207+
- <a name="ref2"></a>[GO Configuration](https://golang.org/doc/code.html)
208+
- <a name="ref3"></a>[GO Environment Variables](https://golang.org/cmd/go/#hdr-Environment_variables)
209+
- <a name="ref4"></a>[GO on Windows Example](http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/)
210+
- <a name="ref5"></a>[Another GO on Windows Example](https://github.com/abourget/getting-started-with-golang/blob/master/Getting_Started_for_Windows.md)

example/hello_gorfc.go

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,32 @@ package main
33
import (
44
"fmt"
55
"reflect"
6-
"testing"
76
"time"
87

98
"github.com/sap/gorfc/gorfc"
10-
"github.com/stretchr/testify/assert"
119
)
1210

13-
func abapSystem() gorfc.ConnectionParameter {
14-
return gorfc.ConnectionParameter{
15-
Dest: "I64",
16-
Client: "800",
17-
User: "demo",
18-
Passwd: "welcome",
19-
Lang: "EN",
20-
Ashost: "10.117.24.158",
21-
Sysnr: "00",
22-
Saprouter: "/H/203.13.155.17/S/3299/W/xjkb3d/H/172.19.137.194/H/",
11+
func abapSystem() gorfc.ConnectionParameters {
12+
return gorfc.ConnectionParameters{
13+
"user": "demo",
14+
"passwd": "welcome",
15+
"ashost": "10.68.110.51",
16+
"sysnr": "00",
17+
"client": "620",
18+
"lang": "EN",
2319
}
2420
}
2521

2622
func main() {
27-
c, _ := gorfc.ConnectionFromParams(abapSystem())
28-
var t *testing.T
23+
c, err := gorfc.ConnectionFromParams(abapSystem())
24+
if err != nil {
25+
fmt.Println(err)
26+
return
27+
}
28+
fmt.Println(c.Alive())
29+
30+
attrs, _ := c.GetConnectionAttributes()
31+
fmt.Println("Connection attributes", attrs)
2932

3033
params := map[string]interface{}{
3134
"IMPORTSTRUCT": map[string]interface{}{
@@ -39,30 +42,22 @@ func main() {
3942
"RFCHEX3": []byte{255, 254, 253},
4043
"RFCTIME": time.Now(),
4144
"RFCDATE": time.Now(),
42-
"RFCDATA1": "Hellö SÄP",
45+
"RFCDATA1": "HELLÖ SÄP",
4346
"RFCDATA2": "DATA222",
4447
},
4548
}
4649
r, _ := c.Call("STFC_STRUCTURE", params)
4750

48-
assert.NotNil(t, r["ECHOSTRUCT"])
51+
fmt.Println(r["ECHOSTRUCT"])
4952
importStruct := params["IMPORTSTRUCT"].(map[string]interface{})
5053
echoStruct := r["ECHOSTRUCT"].(map[string]interface{})
51-
assert.Equal(t, importStruct["RFCFLOAT"], echoStruct["RFCFLOAT"])
52-
assert.Equal(t, importStruct["RFCCHAR1"], echoStruct["RFCCHAR1"])
53-
assert.Equal(t, importStruct["RFCCHAR2"], echoStruct["RFCCHAR2"])
54-
assert.Equal(t, importStruct["RFCCHAR4"], echoStruct["RFCCHAR4"])
55-
assert.Equal(t, importStruct["RFCINT1"], echoStruct["RFCINT1"])
56-
assert.Equal(t, importStruct["RFCINT2"], echoStruct["RFCINT2"])
57-
assert.Equal(t, importStruct["RFCINT4"], echoStruct["RFCINT4"])
58-
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
59-
assert.Equal(t, importStruct["RFCTIME"].(time.Time).Format("150405"), echoStruct["RFCTIME"].(time.Time).Format("150405"))
60-
assert.Equal(t, importStruct["RFCDATE"].(time.Time).Format("20060102"), echoStruct["RFCDATE"].(time.Time).Format("20060102"))
61-
assert.Equal(t, importStruct["RFCDATA1"], echoStruct["RFCDATA1"])
62-
assert.Equal(t, importStruct["RFCDATA2"], echoStruct["RFCDATA2"])
63-
64-
fmt.Println(reflect.TypeOf(importStruct["RFCDATE"]))
65-
fmt.Println(reflect.TypeOf(importStruct["RFCTIME"]))
54+
fmt.Println(echoStruct)
55+
// empty time
56+
fmt.Println(importStruct["RFCDATE"], reflect.TypeOf(importStruct["RFCDATE"]))
57+
fmt.Println(echoStruct["RFCDATE"], reflect.TypeOf(echoStruct["RFCDATE"]))
58+
// empty date
59+
fmt.Println(importStruct["RFCTIME"], reflect.TypeOf(importStruct["RFCTIME"]))
60+
fmt.Println(echoStruct["RFCTIME"], reflect.TypeOf(echoStruct["RFCTIME"]))
6661

6762
c.Close()
6863
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/sap/gorfc
2+
3+
go 1.14
4+
5+
require github.com/stretchr/testify v1.5.1

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
6+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7+
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
8+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
12+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

gorfc/.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 4
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = false

0 commit comments

Comments
 (0)