Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed May 4, 2020
1 parent d5c3c95 commit 4fed1b5
Show file tree
Hide file tree
Showing 10 changed files with 467 additions and 371 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

# RFC traces
*.trc
*.log

# sapnwrfc.ini example
gorfc/sapnwrfc.ini
# gorfc/sapnwrfc.ini

# Packages
GoRFC/pkg/
Expand All @@ -44,3 +45,7 @@ Thumbs.db
*.iml
.idea

### VSCode
.vscode
*.code-workspace

17 changes: 17 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CHANGES
=======

0.0.1 (2016-02-01)
------------------
- Initial release

0.1.0 (2020-05-04)
------------------
- Darwin support
- New connection parameters added, type changed to map
- New connection attributes added, type changed to map
- Table parameter accepts also array of variables
- ABAP datatypes conversions fixed:
- Bytes: RFCTYPE_BYTE, RFCTYPE_XSTRING
- BCD: RFCTYPE_BCD
- ABAP INT8 type added: RFCTYPE_INT8
94 changes: 62 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,66 @@
# SAP NW RFC Connector for [Go](https://golang.org)
[SAP NetWeawer RFC SDK](https://support.sap.com/en/product/connectors/nwrfcsdk.html) client bindings for GO.

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

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).
## Features

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).
- Stateless and stateful connections (multiple function calls in the same ABAP session / same context)
- Automatic conversion between GO and ABAP datatypes

## Table of contents
## Supported Platforms

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

## Platforms and Prerequisites
## Prerequisites

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.
### All platforms

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).
- GOLANG [requirements](https://golang.org/doc/install#requirements)

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.
- 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)

- 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.
- SAP NWRFC SDK [overview](https://support.sap.com/en/product/connectors/nwrfcsdk.html) and [release notes](https://launchpad.support.sap.com/#/softwarecenter/object/0020000000340702020)

- 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)

### Windows

- [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)

- 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

### macOS

- Build toolchain requires GCC and Xcode Command Line Tools:

```shell
$ xcode-select --install
```

- The macOS firewall stealth mode must be disabled ([Can't ping a machine - why?](https://discussions.apple.com/thread/2554739)):

```shell
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
```

- Remote paths must be set in SAP NWRFC SDK for macOS: [documentation](http://sap.github.io/PyRFC/install.html#macos)

- 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)

- Optionally: [valgrind](https://stackoverflow.com/questions/58360093/how-to-install-valgrind-on-macos-catalina-10-15-with-homebrew)

## SPJ articles

Highly recommended reading about RFC communication and SAP NW RFC Library, published in the SAP Professional Journal (SPJ)

- [Part I RFC Client Programming](https://wiki.scn.sap.com/wiki/x/zz27Gg)

- [Part II RFC Server Programming](https://wiki.scn.sap.com/wiki/x/9z27Gg)

- [Part III Advanced Topics](https://wiki.scn.sap.com/wiki/x/FD67Gg)

## Install

Expand Down Expand Up @@ -119,7 +154,7 @@ func abapSystem() gorfc.ConnectionParameter {
Ashost: "11.111.11.111",
Sysnr: "00",
Saprouter: "/H/222.22.222.22/S/2222/W/xxxxx/H/222.22.222.222/H/",
}
}
}

func main() {
Expand All @@ -141,7 +176,7 @@ func main() {
"RFCDATA1": "HELLÖ SÄP",
"RFCDATA2": "DATA222",
},
}
}
r, _ := c.Call("STFC_STRUCTURE", params)

assert.NotNil(t, r["ECHOSTRUCT"])
Expand All @@ -154,7 +189,7 @@ func main() {
assert.Equal(t, importStruct["RFCINT1"], echoStruct["RFCINT1"])
assert.Equal(t, importStruct["RFCINT2"], echoStruct["RFCINT2"])
assert.Equal(t, importStruct["RFCINT4"], echoStruct["RFCINT4"])
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
assert.Equal(t, importStruct["RFCTIME"].(time.Time).Format("150405"), echoStruct["RFCTIME"].(time.Time).Format("15.
assert.Equal(t, importStruct["RFCDATE"].(time.Time).Format("20060102"), e/Users/d037732/Downloads/gorfc/README.mdchoStruct["RFCDATE"].(time.Time).Format(".
assert.Equal(t, importStruct["RFCDATA1"], echoStruct["RFCDATA1"])
Expand All @@ -166,15 +201,10 @@ func main() {
c.Close()
```
## To Do
* Improve the documentation
* Fix Windows compiler flags
## References
* <a name="ref1"></a>[GO Installation](https://golang.org/doc/install)
* <a name="ref2"></a>[GO Configuration](https://golang.org/doc/code.html)
* <a name="ref3"></a>[GO Environment Variables](https://golang.org/cmd/go/#hdr-Environment_variables)
* <a name="ref4"></a>[GO on Windows Example](http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/)
* <a name="ref5"></a>[Another GO on Windows Example](https://github.com/abourget/getting-started-with-golang/blob/master/Getting_Started_for_Windows.md)
- <a name="ref1"></a>[GO Installation](https://golang.org/doc/install)
- <a name="ref2"></a>[GO Configuration](https://golang.org/doc/code.html)
- <a name="ref3"></a>[GO Environment Variables](https://golang.org/cmd/go/#hdr-Environment_variables)
- <a name="ref4"></a>[GO on Windows Example](http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/)
- <a name="ref5"></a>[Another GO on Windows Example](https://github.com/abourget/getting-started-with-golang/blob/master/Getting_Started_for_Windows.md)
57 changes: 26 additions & 31 deletions example/hello_gorfc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@ package main
import (
"fmt"
"reflect"
"testing"
"time"

"github.com/sap/gorfc/gorfc"
"github.com/stretchr/testify/assert"
)

func abapSystem() gorfc.ConnectionParameter {
return gorfc.ConnectionParameter{
Dest: "I64",
Client: "800",
User: "demo",
Passwd: "welcome",
Lang: "EN",
Ashost: "10.117.24.158",
Sysnr: "00",
Saprouter: "/H/203.13.155.17/S/3299/W/xjkb3d/H/172.19.137.194/H/",
func abapSystem() gorfc.ConnectionParameters {
return gorfc.ConnectionParameters{
"user": "demo",
"passwd": "welcome",
"ashost": "10.68.110.51",
"sysnr": "00",
"client": "620",
"lang": "EN",
}
}

func main() {
c, _ := gorfc.ConnectionFromParams(abapSystem())
var t *testing.T
c, err := gorfc.ConnectionFromParams(abapSystem())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(c.Alive())

attrs, _ := c.GetConnectionAttributes()
fmt.Println("Connection attributes", attrs)

params := map[string]interface{}{
"IMPORTSTRUCT": map[string]interface{}{
Expand All @@ -39,30 +42,22 @@ func main() {
"RFCHEX3": []byte{255, 254, 253},
"RFCTIME": time.Now(),
"RFCDATE": time.Now(),
"RFCDATA1": "Hellö SÄP",
"RFCDATA1": "HELLÖ SÄP",
"RFCDATA2": "DATA222",
},
}
r, _ := c.Call("STFC_STRUCTURE", params)

assert.NotNil(t, r["ECHOSTRUCT"])
fmt.Println(r["ECHOSTRUCT"])
importStruct := params["IMPORTSTRUCT"].(map[string]interface{})
echoStruct := r["ECHOSTRUCT"].(map[string]interface{})
assert.Equal(t, importStruct["RFCFLOAT"], echoStruct["RFCFLOAT"])
assert.Equal(t, importStruct["RFCCHAR1"], echoStruct["RFCCHAR1"])
assert.Equal(t, importStruct["RFCCHAR2"], echoStruct["RFCCHAR2"])
assert.Equal(t, importStruct["RFCCHAR4"], echoStruct["RFCCHAR4"])
assert.Equal(t, importStruct["RFCINT1"], echoStruct["RFCINT1"])
assert.Equal(t, importStruct["RFCINT2"], echoStruct["RFCINT2"])
assert.Equal(t, importStruct["RFCINT4"], echoStruct["RFCINT4"])
// assert.Equal(t, importStruct["RFCHEX3"], echoStruct["RFCHEX3"])
assert.Equal(t, importStruct["RFCTIME"].(time.Time).Format("150405"), echoStruct["RFCTIME"].(time.Time).Format("150405"))
assert.Equal(t, importStruct["RFCDATE"].(time.Time).Format("20060102"), echoStruct["RFCDATE"].(time.Time).Format("20060102"))
assert.Equal(t, importStruct["RFCDATA1"], echoStruct["RFCDATA1"])
assert.Equal(t, importStruct["RFCDATA2"], echoStruct["RFCDATA2"])

fmt.Println(reflect.TypeOf(importStruct["RFCDATE"]))
fmt.Println(reflect.TypeOf(importStruct["RFCTIME"]))
fmt.Println(echoStruct)
// empty time
fmt.Println(importStruct["RFCDATE"], reflect.TypeOf(importStruct["RFCDATE"]))
fmt.Println(echoStruct["RFCDATE"], reflect.TypeOf(echoStruct["RFCDATE"]))
// empty date
fmt.Println(importStruct["RFCTIME"], reflect.TypeOf(importStruct["RFCTIME"]))
fmt.Println(echoStruct["RFCTIME"], reflect.TypeOf(echoStruct["RFCTIME"]))

c.Close()
}
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/sap/gorfc

go 1.14

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

[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
Loading

0 comments on commit 4fed1b5

Please sign in to comment.