This public repository is no longer maintained. Please see this issue for details.
For more details on the SAP NetWeaver Remote Function Call (RFC) Software Development Kit (SDK) please see its support page.
- Stateless and stateful connections (multiple function calls in the same ABAP session / same context)
- Automatic conversion between GO and ABAP datatypes
-
macOS, Linux
-
Windows is not supported until the #21 fixed
-
GOLANG requirements
-
SAP NWRFC SDK 7.50 PL3 or later must be downloaded (SAP partner or customer account required) and locally installed
- 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 and release notes
-
Build from source on macOS and older Linux systems, may require
uchar.h
file, attached to SAP OSS Note 2573953, to be copied to SAP NWRFC SDK include directory: documentation
-
Visual C++ Redistributable Package for Visual Studio 2013 is required for runtime, see SAP Note 2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50
-
Build toolchain requires GCC and MinGW. Using TDM_GCC may lead to issues: https://stackoverflow.com/questions/35004744/golang-oci8-error-adding-symbols-file-in-wrong-format
-
Install the latest MinGW-w64, keeping offered defaults
- Build toolchain requires GCC and Xcode Command Line Tools:
$ xcode-select --install
- The macOS firewall stealth mode must be disabled (Can't ping a machine - why?):
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off
-
Remote paths must be set in SAP NWRFC SDK for macOS: documentation
-
Build from source requires
uchar.h
file, attached to SAP OSS Note 2573953, to be copied to SAP NWRFC SDK include directory: documentation -
Optionally: valgrind
Highly recommended reading about RFC communication and SAP NW RFC Library, published in the SAP Professional Journal (SPJ)
To start using SAP NW RFC Connector for Go, you shall:
If you are new to Go, the Go distribution shall be installed first, following GO Installation and GO Configuration instructions. See also GO Environment Variables.
After running the MSI installer, the default C:\Go folder is created and the GOROOT system variable is set to C:\Go.
Create the Go work environment directory:
cd c:\
mkdir workspace
Set the environment user varialbes GOPATH and GOBIN, add the bin subdirectories to PATH and restart the Windows shell.
GOPATH = C:\workspace
GOBIN = %GOPATH%\bin
PATH = %GOROOT%\bin;%GOBIN%:%PATH%
See also GO on Windows Example.
The work environment setup works the same way like on Windows and these instructions describe the installation on Ubuntu Linux for example.
To obtain and install SAP NW RFC Library from SAP Service Marketplace, you can follow the same instructions as for Python or nodejs RFC connectors.
To install gorfc and dependencies, run following commands:
export CGO_CFLAGS="-I $SAPNWRFC_HOME/include"
export CGO_LDFLAGS="-L $SAPNWRFC_HOME/lib"
export CGO_CFLAGS_ALLOW=.*
export CGO_LDFLAGS_ALLOW=.*
go get github.com/stretchr/testify
go get github.com/sap/gorfc
cd $GOPATH/src/github.com/sap/gorfc/gorfc
go build
go install
To test the installation, run the example provided:
cd $GOPATH/src/github.com/sap/gorfc/example
go run hello_gorfc.go
See the hello_gorfc.go example and gorfc_test.go unit tests.
The GO RFC Connector follows the same principles and the implementation model of Python and nodejs RFC connectors and you may check examples and documentation there as well.
package main
import (
"fmt"
"github.com/sap/gorfc/gorfc"
"github.com/stretchr/testify/assert"
"reflect"
"testing"
"time"
)
func abapSystem() gorfc.ConnectionParameter {
return gorfc.ConnectionParameter{
Dest: "I64",
Client: "800",
User: "demo",
Passwd: "welcome",
Lang: "EN",
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() {
c, _ := gorfc.Connection(abapSystem())
var t *testing.T
params := map[string]interface{}{
"IMPORTSTRUCT": map[string]interface{}{
"RFCFLOAT": 1.23456789,
"RFCCHAR1": "A",
"RFCCHAR2": "BC",
"RFCCHAR4": "ÄBC",
"RFCINT1": 0xfe,
"RFCINT2": 0x7ffe,
"RFCINT4": 999999999,
"RFCHEX3": []byte{255, 254, 253},
"RFCTIME": time.Now(),
"RFCDATE": time.Now(),
"RFCDATA1": "HELLÖ SÄP",
"RFCDATA2": "DATA222",
},
}
r, _ := c.Call("STFC_STRUCTURE", params)
assert.NotNil(t, 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("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"])
assert.Equal(t, importStruct["RFCDATA2"], echoStruct["RFCDATA2"])
fmt.Println(reflect.TypeOf(importStruct["RFCDATE"]))
fmt.Println(reflect.TypeOf(importStruct["RFCTIME"]))
c.Close()
Please see our LICENSE file for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.