All Projects → SAP → Gorfc

SAP / Gorfc

Licence: apache-2.0
SAP NW RFC Connector for GO

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gorfc

Secuela Variable
Secuela Sans & Condensed - Variable Font OFL
Stars: ✭ 62 (-6.06%)
Mutual labels:  open-source
Openvoiceos
OpenVoiceOS is a minimalistic linux OS bringing the open source voice assistant Mycroft A.I. to embbeded, low-spec headless and/or small (touch)screen devices.
Stars: ✭ 64 (-3.03%)
Mutual labels:  open-source
One Line Wonders
OneLineWondersCode | 1000+ Commits | 278/300 One Liners | 200+ Forks | Actively maintained open-source collection of "one-line" programs performing various tasks in different languages
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source
Startbootstrap Grayscale
A multipurpose one page Bootstrap theme created by Start Bootstrap
Stars: ✭ 1,120 (+1596.97%)
Mutual labels:  open-source
Hacktoberfest2019
A repository to contribute to Hacktoberfest 2019
Stars: ✭ 64 (-3.03%)
Mutual labels:  open-source
Books
Free Desktop book-keeping software for small-businesses and freelancers.
Stars: ✭ 1,132 (+1615.15%)
Mutual labels:  open-source
Nordic Store
Tailwind CSS Starter Template - Nordic Shop / Store
Stars: ✭ 61 (-7.58%)
Mutual labels:  open-source
Gojis
An ECMAScript 2018 (ES9) implementation in Go
Stars: ✭ 66 (+0%)
Mutual labels:  open-source
Nat
nat - the 'ls' replacement you never knew you needed
Stars: ✭ 1,129 (+1610.61%)
Mutual labels:  open-source
Ctag Straempler
An open source eurorack sample streaming and sound synthesis module.
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source
Webuild
📝 Robot-handpicked list of open events and open source for designers, developers and makers in Singapore
Stars: ✭ 62 (-6.06%)
Mutual labels:  open-source
Sapl
Sistema de Apoio ao Processo Legislativo
Stars: ✭ 63 (-4.55%)
Mutual labels:  open-source
Awesome Readme
A guide to writing an Awesome README. Read the full article in Towards Data Science.
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source
Module 5 Open Research Software And Open Source
Module 5: Open Research Software and Open Source
Stars: ✭ 62 (-6.06%)
Mutual labels:  open-source
Beta
An open source reimplementation of Benny Brodda's BETA in Python
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source
Dsm Storybook Example Library
Stars: ✭ 62 (-6.06%)
Mutual labels:  open-source
Pivorak Web App
Rails App for PivorakMeetup
Stars: ✭ 64 (-3.03%)
Mutual labels:  open-source
Android Java Chat App
Open-source Voice & Video Calling and Text Chat App for Java (Android)
Stars: ✭ 66 (+0%)
Mutual labels:  open-source
Shadowsocksfree
Try Yourself.
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source
Neutron
Neutron is a CLI developed to help developers create new react projects with Redux + Redux Saga and offers well-structured code standardization.
Stars: ✭ 65 (-1.52%)
Mutual labels:  open-source

❗️ Don't upgrade SAP NWRFC SDK on Darwin, see #143

SAP NetWeawer RFC SDK client bindings for GO.

license Go Report Card GoDoc

Features

  • Stateless and stateful connections (multiple function calls in the same ABAP session / same context)
  • Automatic conversion between GO and ABAP datatypes

Supported Platforms

  • macOS, Linux

  • Windows is not supported until the #21 fixed

Prerequisites

All platforms

  • 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

Windows

macOS

  • Build toolchain requires GCC and Xcode Command Line Tools:
$ xcode-select --install
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode off

SPJ articles

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

Install

To start using SAP NW RFC Connector for Go, you shall:

  1. Install and Configure Go
  2. Install the SAP NW RFC Library for your platform
  3. Install the GORFC package

Install and Configure Go

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.

Windows Config Example

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.

Linux

The work environment setup works the same way like on Windows and these instructions describe the installation on Ubuntu Linux for example.

Install SAP NW RFC Library

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.

Install GORFC

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

Getting Started

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

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].