Coder Social home page Coder Social logo

gorfc's Introduction

SAP NetWeawer RFC SDK client bindings for GO

For more details on the SAP NetWeaver Remote Function Call (RFC) Software Development Kit (SDK) please see its support page.

license REUSE status 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

Requirements

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)

Installation

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

Licensing

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.

References

gorfc's People

Contributors

antihax avatar auhlig avatar bsrdjan avatar databus23 avatar jonasdann avatar sebastianwolf-sap avatar simonwaldherr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gorfc's Issues

mac installation error

Maos documents and my friends around me are confused. Can you be more specific and separate from python?

gorfc API to fetch the Line Type for custom RFC

Hello,

I am working on a custom RFC (Z_TEST_COMPLEX_TT_EXP) whose definition is available in the attached document.
For I_SIMPLE interface, on clicking on TYPE MAND_TYPE, second screenshot from the document displays the Line Type details. It also shows MANDT name for the Line Type.

Now, I am trying to fetch the metadata for Z_TEST_COMPLEX_TT_EXP using GetFunctionDescription method.
funcDesc, _ := conn.GetFunctionDescription(rfcName)

But I do not see any struct field that holds information MANDT. Can you please highlight how can I fetch the same by either using same API or different API?

Using JCO library, I am able to get above information using metaData.getRecordTypeName(i) where metaData is of Type com.sap.conn.jco.JCoRecordMetaData

I am doing a POC to change the existing code from using JCO library to gorfc and wanted to understand how I can take care of above usecase with gorfc.

Attaching the RFC definition for reference.
RFCDefinition.docx

RFCTYPE_BCD Conversion error being inconsistent

Dear Maintainer,

We have issue with SAP Datatype PACKED - we are getting RFC_CONVERSION_FAILURE even though we have follow pretty much all the advise that ChatGPT has throw at us. We have a datatype PACKED 7 in one of the builtin SAP RFC - we try to fill it with 0.000 value and sometime it throws us error of conversion and sometimes it lets us go through clean. It is inconsistent error and success being thrown at us

Here are couple conversion code that are being inconsistent:

-----CODE USED ---
var qty1Str string = "1.000"
encodeQty1Big, _, err := big.ParseFloat(qty1Str, 10, 3, big.ToNearestEven)
if err != nil {
panic(err)
}
----- RESULT ERROR
Fail NWRFC SDK error: Could not fill COND_VALUE of type 2 | rfcSDKError[Cannot convert string value <*big.Float Value> at position 0 for the field COND_VALUE to type RFCTYPE_BCD, RFC_CONVERSION_FAILURE, RFC_CONVERSION_FAILURE, , , , , , , ]

---- CODE USED ---
func ConvertToBCDArg(value float64, precision uint) ([]byte, error) {
// Convert the float64 value to a decimal with 15 digits and 2 decimal places
decimalValue := big.NewFloat(value).SetPrec(precision).SetMode(big.ToNearestEven)

// Convert the decimal value to a byte array in BCD format
bcdValue, err := decimalValue.MarshalText()
if err != nil {
	return nil, err
}

// Reverse the byte order to match SAP's BCD format
reverseBytes(bcdValue)

// Return the BCD byte array
return bcdValue, nil

}

func reverseBytes(b []byte) {
for i := 0; i < len(b)/2; i++ {
j := len(b) - i - 1
b[i], b[j] = b[j], b[i]
}
}
----- RESULT of ERROR

Fail NWRFC SDK error: Could not fill REQ_QTY of type 2 | rfcSDKError[Cannot convert string value <[]uint8 Value> for the field REQ_QTY to type RFCTYPE_BCD, RFC_CONVERSION_FAILURE, RFC_CONVERSION_FAILURE, , , , , , , ]

Could not get the parameter description for "STRING" Error

In runtime when we pass input parameter as map[INT:[map[STRING:1]]] we get error that STRING is invalid RFC parameter but when we pass input parameter as map[INT:[1]] it works. We suspect that the "STRING" parameter which we are receiving at design time is not correct.
Can you suggest what could be the issue?

Passing blank values in parameters of type "C"

Want to pass a single character as space in input params.
Something like this:
c, _ := gorfc.ConnectionFromParams(abapSystem())
params := map[string]interface{}{
"CALL_RFC":" ",
}
r, e := c.Call("Z_ALLDATATYPE_CLIENT_TEST1", params)
if e != nil {
fmt.Println("Error is:", e)
}
Here after Call, no error is returned and exit status 0xc0000374.
Can you suggest what could be the issue?

Segfault RfcUTF8ToSAPUC

OS: Win10
go version go1.10.1 windows/amd64
nwrfcsdk version 7.20 x86/64

the function fillString causes a segfault at line 96 callling RfcUTF8ToSAPUC in the nwrfcsdk. Looking at the code it looks fine for me though.

Error while calling GetFunctionDescription

Hello, I am trying to call GetFunctionDescription function for my Function in SAP. I am getiing following error:

go version go1.12 linux/amd64

`
*** glibc detected *** ./hello_gorfc: free(): invalid next size (fast): 0x0000000000cc3590 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3800c75dee]
/lib64/libc.so.6[0x3800c78c80]
./hello_gorfc[0x454630]
======= Memory map: ========
00400000-00597000 r-xp 00000000 fd:05 806929 /home/faisal/goPath/src/github.com/sap/gorfc/example/hello_gorfc
00796000-007ab000 rw-p 00196000 fd:05 806929 /home/faisal/goPath/src/github.com/sap/gorfc/example/hello_gorfc
007ab000-007c9000 rw-p 00000000 00:00 0
00c58000-00d47000 rw-p 00000000 00:00 0 [heap]
3800400000-3800420000 r-xp 00000000 fd:00 393246 /lib64/ld-2.12.so
3800620000-3800621000 r--p 00020000 fd:00 393246 /lib64/ld-2.12.so
3800621000-3800622000 rw-p 00021000 fd:00 393246 /lib64/ld-2.12.so
3800622000-3800623000 rw-p 00000000 00:00 0
3800800000-3800802000 r-xp 00000000 fd:00 393600 /lib64/libdl-2.12.so
3800802000-3800a02000 ---p 00002000 fd:00 393600 /lib64/libdl-2.12.so
3800a02000-3800a03000 r--p 00002000 fd:00 393600 /lib64/libdl-2.12.so
3800a03000-3800a04000 rw-p 00003000 fd:00 393600 /lib64/libdl-2.12.so
3800c00000-3800d8a000 r-xp 00000000 fd:00 393264 /lib64/libc-2.12.so
3800d8a000-3800f8a000 ---p 0018a000 fd:00 393264 /lib64/libc-2.12.so
3800f8a000-3800f8e000 r--p 0018a000 fd:00 393264 /lib64/libc-2.12.so
3800f8e000-3800f90000 rw-p 0018e000 fd:00 393264 /lib64/libc-2.12.so
3800f90000-3800f94000 rw-p 00000000 00:00 0
3801000000-3801017000 r-xp 00000000 fd:00 393297 /lib64/libpthread-2.12.so
3801017000-3801217000 ---p 00017000 fd:00 393297 /lib64/libpthread-2.12.so
3801217000-3801218000 r--p 00017000 fd:00 393297 /lib64/libpthread-2.12.so
3801218000-3801219000 rw-p 00018000 fd:00 393297 /lib64/libpthread-2.12.so
3801219000-380121d000 rw-p 00000000 00:00 0
3801400000-3801407000 r-xp 00000000 fd:00 393669 /lib64/librt-2.12.so
3801407000-3801606000 ---p 00007000 fd:00 393669 /lib64/librt-2.12.so
3801606000-3801607000 r--p 00006000 fd:00 393669 /lib64/librt-2.12.so
3801607000-3801608000 rw-p 00007000 fd:00 393669 /lib64/librt-2.12.so
3801800000-3801883000 r-xp 00000000 fd:00 393284 /lib64/libm-2.12.so
3801883000-3801a82000 ---p 00083000 fd:00 393284 /lib64/libm-2.12.so
3801a82000-3801a83000 r--p 00082000 fd:00 393284 /lib64/libm-2.12.so
3801a83000-3801a84000 rw-p 00083000 fd:00 393284 /lib64/libm-2.12.so
3803000000-3803016000 r-xp 00000000 fd:00 393291 /lib64/libgcc_s-4.4.7-20120601.so.1
3803016000-3803215000 ---p 00016000 fd:00 393291 /lib64/libgcc_s-4.4.7-20120601.so.1
3803215000-3803216000 rw-p 00015000 fd:00 393291 /lib64/libgcc_s-4.4.7-20120601.so.1
3803c00000-3803c04000 r-xp 00000000 fd:00 393673 /lib64/libuuid.so.1.3.0
3803c04000-3803e03000 ---p 00004000 fd:00 393673 /lib64/libuuid.so.1.3.0
3803e03000-3803e04000 rw-p 00003000 fd:00 393673 /lib64/libuuid.so.1.3.0
3ab9200000-3ab92e8000 r-xp 00000000 fd:00 2885907 /usr/lib64/libstdc++.so.6.0.13
3ab92e8000-3ab94e8000 ---p 000e8000 fd:00 2885907 /usr/lib64/libstdc++.so.6.0.13
3ab94e8000-3ab94ef000 r--p 000e8000 fd:00 2885907 /usr/lib64/libstdc++.so.6.0.13
3ab94ef000-3ab94f1000 rw-p 000ef000 fd:00 2885907 /usr/lib64/libstdc++.so.6.0.13
3ab94f1000-3ab9506000 rw-p 00000000 00:00 0
c000000000-c004000000 rw-p 00000000 00:00 0
7ffba0000000-7ffba0021000 rw-p 00000000 00:00 0
7ffba0021000-7ffba4000000 ---p 00000000 00:00 0
7ffba5a2c000-7ffba6a2d000 rw-p 00000000 00:00 0
7ffba6a2d000-7ffba7e00000 r--p 00000000 fd:05 806053 /home/faisal/sap/linux/nwrfcsdk/lib/libicudata.so.50
7ffba7e00000-7ffba7fff000 ---p 013d3000 fd:05 806053 /home/faisal/sap/linux/nwrfcsdk/lib/libicudata.so.50
7ffba7fff000-7ffba8000000 r--p 013d2000 fd:05 806053 /home/faisal/sap/linux/nwrfcsdk/lib/libicudata.so.50
7ffba8000000-7ffba8021000 rw-p 00000000 00:00 0
7ffba8021000-7ffbac000000 ---p 00000000 00:00 0
7ffbac4fd000-7ffbac50a000 r-xp 00000000 fd:00 393247 /lib64/libnss_files-2.12.so
7ffbac50a000-7ffbac709000 ---p 0000d000 fd:00 393247 /lib64/libnss_files-2.12.so
7ffbac709000-7ffbac70a000 r--p 0000c000 fd:00 393247 /lib64/libnss_files-2.12.so
7ffbac70a000-7ffbac70b000 rw-p 0000d000 fd:00 393247 /lib64/libnss_files-2.12.so
7ffbac716000-7ffbac817000 rw-p 00000000 00:00 0
7ffbac817000-7ffbaca56000 r-xp 00000000 fd:05 806056 /home/faisal/sap/linux/nwrfcsdk/lib/libicui18n.so.50
7ffbaca56000-7ffbacc56000 ---p 0023f000 fd:05 806056 /home/faisal/sap/linux/nwrfcsdk/lib/libicui18n.so.50
7ffbacc56000-7ffbacc63000 r--p 0023f000 fd:05 806056 /home/faisal/sap/linux/nwrfcsdk/lib/libicui18n.so.50
7ffbacc63000-7ffbacc64000 rw-p 0024c000 fd:05 806056 /home/faisal/sap/linux/nwrfcsdk/lib/libicui18n.so.50
7ffbacc64000-7ffbacc65000 rw-p 00000000 00:00 0
7ffbacc65000-7ffbace3a000 r-xp 00000000 fd:05 806057 /home/faisal/sap/linux/nwrfcsdk/lib/libicuuc.so.50
7ffbace3a000-7ffbad03a000 ---p 001d5000 fd:05 806057 /home/faisal/sap/linux/nwrfcsdk/lib/libicuuc.so.50
7ffbad03a000-7ffbad04a000 r--p 001d5000 fd:05 806057 /home/faisal/sap/linux/nwrfcsdk/lib/libicuuc.so.50
7ffbad04a000-7ffbad04b000 rw-p 001e5000 fd:05 806057 /home/faisal/sap/linux/nwrfcsdk/lib/libicuuc.so.50
7ffbad04b000-7ffbad090000 rw-p 00000000 00:00 0
7ffbad090000-7ffbad091000 ---p 00000000 00:00 0
7ffbad091000-7ffbada91000 rw-p 00000000 00:00 0 SIGABRT: abort
PC=0x3800c32495 m=0 sigcode=18446744073709551610

goroutine 0 [idle]:
runtime: unknown pc 0x3800c32495
stack: frame={sp:0x7ffdc37dd208, fp:0x0} stack=[0x7ffdc2dded70,0x7ffdc37ddd90)
00007ffdc37dd108: 0000000000000000 0000000000000000
00007ffdc37dd118: 0000000000000000 0000000000000000
00007ffdc37dd128: 0000000000000000 0000000000000000
00007ffdc37dd138: 0000000000000000 0000000000000000
00007ffdc37dd148: 0000000000000000 0000000000000000
00007ffdc37dd158: 0000000000000000 0000000000000000
00007ffdc37dd168: 0000000000000000 0000000000000000
00007ffdc37dd178: 0000000000000000 0000000000000000
00007ffdc37dd188: 0000003800d26d4c 00000c0100000000
00007ffdc37dd198: 00007ffdc37dd2f8 0000000000000000
00007ffdc37dd1a8: 0000000000401660 0000000000000000
00007ffdc37dd1b8: 0000003800ce0cc0 0000000000000002
00007ffdc37dd1c8: 0000000000000004 00007ffdc37dd220
00007ffdc37dd1d8: 0000000000000400 00007ffdc37ddc50
00007ffdc37dd1e8: 0000000000000005 00007ffdc37dd530
00007ffdc37dd1f8: 000000000000005f 0000000000000007
00007ffdc37dd208: <0000003800c33c75 00007ffdc37dd2f8
00007ffdc37dd218: 00007ffdc37dd2e0 00007ffdc37df38a
00007ffdc37dd228: 000000000000000d 0000003800d5798f
00007ffdc37dd238: 0000000000000003 00007ffdc37dd2ea
00007ffdc37dd248: 0000000000000006 0000003800d57993
00007ffdc37dd258: 0000000000000002 0000000000000000
00007ffdc37dd268: 0000000000000000 0000000000000000
00007ffdc37dd278: 0000003800c78650 4000000000000000
00007ffdc37dd288: 0000000000000000 0000000000000000
00007ffdc37dd298: 0000000000000000 0000000000000000
00007ffdc37dd2a8: 0000000000000000 0000000000000020
00007ffdc37dd2b8: 0000000000000000 0000000000000000
00007ffdc37dd2c8: 0000000000000000 0000000000000000
00007ffdc37dd2d8: 0000000000000000 0000000000000000
00007ffdc37dd2e8: 0000000000000000 0000000000000000
00007ffdc37dd2f8: 0000000000000000 0000000000000000
runtime: unknown pc 0x3800c32495
stack: frame={sp:0x7ffdc37dd208, fp:0x0} stack=[0x7ffdc2dded70,0x7ffdc37ddd90)
00007ffdc37dd108: 0000000000000000 0000000000000000
00007ffdc37dd118: 0000000000000000 0000000000000000
00007ffdc37dd128: 0000000000000000 0000000000000000
00007ffdc37dd138: 0000000000000000 0000000000000000
00007ffdc37dd148: 0000000000000000 0000000000000000
00007ffdc37dd158: 0000000000000000 0000000000000000
00007ffdc37dd168: 0000000000000000 0000000000000000
00007ffdc37dd178: 0000000000000000 0000000000000000
00007ffdc37dd188: 0000003800d26d4c 00000c0100000000
00007ffdc37dd198: 00007ffdc37dd2f8 0000000000000000
00007ffdc37dd1a8: 0000000000401660 0000000000000000
00007ffdc37dd1b8: 0000003800ce0cc0 0000000000000002
00007ffdc37dd1c8: 0000000000000004 00007ffdc37dd220
00007ffdc37dd1d8: 0000000000000400 00007ffdc37ddc50
00007ffdc37dd1e8: 0000000000000005 00007ffdc37dd530
00007ffdc37dd1f8: 000000000000005f 0000000000000007
00007ffdc37dd208: <0000003800c33c75 00007ffdc37dd2f8
00007ffdc37dd218: 00007ffdc37dd2e0 00007ffdc37df38a
00007ffdc37dd228: 000000000000000d 0000003800d5798f
00007ffdc37dd238: 0000000000000003 00007ffdc37dd2ea
00007ffdc37dd248: 0000000000000006 0000003800d57993
00007ffdc37dd258: 0000000000000002 0000000000000000
00007ffdc37dd268: 0000000000000000 0000000000000000
00007ffdc37dd278: 0000003800c78650 4000000000000000
00007ffdc37dd288: 0000000000000000 0000000000000000
00007ffdc37dd298: 0000000000000000 0000000000000000
00007ffdc37dd2a8: 0000000000000000 0000000000000020
00007ffdc37dd2b8: 0000000000000000 0000000000000000
00007ffdc37dd2c8: 0000000000000000 0000000000000000
00007ffdc37dd2d8: 0000000000000000 0000000000000000
00007ffdc37dd2e8: 0000000000000000 0000000000000000
00007ffdc37dd2f8: 0000000000000000 0000000000000000

goroutine 1 [syscall]:
runtime.cgocall(0x4b08f0, 0xc00010cdc8, 0xc000000000)
/data/goLang/NoCGRates/src/runtime/cgocall.go:128 +0x5b fp=0xc00010cd98 sp=0xc00010cd60 pc=0x405f8b
github.com/sap/gorfc/gorfc._Cfunc_free(0xcc3590)
_cgo_gotypes.go:1086 +0x41 fp=0xc00010cdc8 sp=0xc00010cd98 pc=0x49df41
github.com/sap/gorfc/gorfc.wrapTypeDescription.func1.1()
/home/faisal/goPath/src/github.com/sap/gorfc/gorfc/gorfc.go:458 +0x5a fp=0xc00010ce08 sp=0xc00010cdc8 pc=0x4aae4a
github.com/sap/gorfc/gorfc.wrapTypeDescription(0xccb2a0, 0xc000016c00, 0x1c, 0x1cb, 0x390, 0xc000130800, 0xa, 0x10, 0x0, 0x0)
/home/faisal/goPath/src/github.com/sap/gorfc/gorfc/gorfc.go:516 +0x6e5 fp=0xc00010f168 sp=0xc00010ce08 pc=0x4a3335
github.com/sap/gorfc/gorfc.wrapFunctionDescription(0xcc37b0, 0xc000016b40, 0x1b, 0xc000140000, 0x3, 0x4, 0x0, 0x0)
/home/faisal/goPath/src/github.com/sap/gorfc/gorfc/gorfc.go:614 +0x5cc fp=0xc000110e70 sp=0xc00010f168 pc=0x4a405c
github.com/sap/gorfc/gorfc.(*Connection).GetFunctionDescription(0xc0000841b0, 0x4ed275, 0x1b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/faisal/goPath/src/github.com/sap/gorfc/gorfc/gorfc.go:1105 +0x133 fp=0xc000111ca8 sp=0xc000110e70 pc=0x4a84c3
main.main()
/home/faisal/goPath/src/github.com/sap/gorfc/example/hello_gorfc.go:90 +0x11f7 fp=0xc000111f98 sp=0xc000111ca8 pc=0x4b02a7
runtime.main()
/data/goLang/NoCGRates/src/runtime/proc.go:200 +0x20c fp=0xc000111fe0 sp=0xc000111f98 pc=0x42d62c
runtime.goexit()
/data/goLang/NoCGRates/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc000111fe8 sp=0xc000111fe0 pc=0x454eb1

rax 0x0
rbx 0x400
rcx 0xffffffffffffffff
rdx 0x6
rdi 0x18f77
rsi 0x18f77
rbp 0x7ffdc37ddc50
rsp 0x7ffdc37dd208
r8 0x0
r9 0x4b0bf0
r10 0x8
r11 0x206
r12 0x5
r13 0x7ffdc37dd530
r14 0x5f
r15 0x7
rip 0x3800c32495
rflags 0x206
cs 0x33
fs 0x0
gs 0x0
`

Please help.

how to handle more examples

are there any ideas on how to handle more examples?

  • have a file with links to repos using this package
  • store multiple example files in the example folder
  • both of the above, first for bigger examples, second for smaller ones

Add the tables parameter to feedback the error

There is no problem using the following code

c, _ := gorfc.ConnectionFromParams(abapSystem())
	/**var t *testing.T**/
	
	in_date1, _ := time.Parse("20060102", "20190101")
	in_date2, _ := time.Parse("20060102", "20190701")
	params := map[string]interface{}{
		"I_FDATE": in_date1,
		"I_TDATE": in_date2,
		"I_RFC": "RFC",
	}

but add the tables parameter to feedback the error

c, _ := gorfc.ConnectionFromParams(abapSystem())
	/**var t *testing.T**/
	
	in_date1, _ := time.Parse("20060102", "20190101")
	in_date2, _ := time.Parse("20060102", "20190701")
	params := map[string]interface{}{
		"I_FDATE": in_date1,
		"I_TDATE": in_date2,
		"I_RFC": "RFC",
		"T_BUKRS": map[string]interface{}{
			"BUKRS": "1270",
		},	
	}

error info:

[root@localhost example]# go run hello_gorfc.go
panic: reflect: call of reflect.Value.Index on map Value

goroutine 1 [running]:
reflect.Value.Index(0x4c65a0, 0xc420068180, 0x15, 0x0, 0x15, 0xc42009a300, 0x0)
	/usr/local/go/src/reflect/value.go:894 +0x1a8
github.com/sap/gorfc/gorfc.fillTable(0xe221d0, 0xe1c740, 0x4c65a0, 0xc420068180, 0x0, 0xe16a10)
	/root/Code/go/src/github.com/sap/gorfc/gorfc/gorfc.go:245 +0x18e
github.com/sap/gorfc/gorfc.fillVariable(0x5, 0xe16610, 0xc42008e420, 0x4c65a0, 0xc420068180, 0xe221d0, 0x0, 0x0)
	/root/Code/go/src/github.com/sap/gorfc/gorfc/gorfc.go:152 +0x769
github.com/sap/gorfc/gorfc.fillFunctionParameter(0xe15a90, 0xe16610, 0x4e065b, 0x7, 0x4c65a0, 0xc420068180, 0x0, 0x0)
	/root/Code/go/src/github.com/sap/gorfc/gorfc/gorfc.go:126 +0x297
github.com/sap/gorfc/gorfc.(*Connection).Call(0xc420068150, 0x4e3516, 0x19, 0x4c65a0, 0xc4200681b0, 0x0, 0x0, 0x0)
	/root/Code/go/src/github.com/sap/gorfc/gorfc/gorfc.go:1073 +0x3b6
main.main()
	/root/Code/go/src/github.com/sap/gorfc/example/hello_gorfc.go:40 +0x46c
exit status 2

BUKRS type is char

Ask everybody elder brother to help have a look. tks...

Example program "hello_gorfc", sometimes it works and sometimes it doesn't

Hello, I compiled the source program "hello_gorfc.go" that you have as an example. The environment is Windows 10, using go 1.14.3, and the last version of sapnwrfc (7.50.6).
When I execute this program many times in a minute, sometimes I get the expected results displayed and sometimes it displays nothing, there is not a uniform behavior.
I also have some programs I wrote and the behavior of these is the same; what do you thing Is happening?
Try the example program, may be you can have the same results.
Best regards.

Unable to run the go.file

I am facing the below issue when i try to run the go.file on Windows

PFB the error:

D:\Go_Folder\src\sap_con>go run sap_connection.go #github.com/sap/gorfc/gorfc ....\pkg\mod\github.com\sap\[email protected]\gorfc\gorfc.go:52:10: fatal error: sapnwrfc.h:
No such file or directory #include <sapnwrfc.h> compilation terminated.

Please suggest.

while go get github.com/sap/gorfc no Go files in /go/src/github.com/sap/gorfc

go version 1.15.6.

while run go get github/sap/gorfc
I get a warning package github.com/sap/gorfc: no Go files in /go/src/github.com/sap/gorfc

$go get github.com/sap/gorfc
package github.com/sap/gorfc: no Go files in /go/src/github.com/sap/gorfc

the go files actually in /go/src/github.com/sap/gorfc/gorfc/
although it can be work ,
还是讲中文吧, 讲英语太累了。。。
新版本的go 在加载这个包的时候, 会抛出这个警告, 虽然它不影响实际使用, 但是这个警告还是处理一下的好。

Unable to build in Windows: undetermined C.RfcGetInt8

Trying to build package:

PS C:\Users\ppiaggio\go\src\github.com\sap\gorfc\gorfc> go build
# github.com/sap/gorfc/gorfc
.\gorfc.go:816:8: could not determine kind of name for C.RfcGetInt8

Environment:

PS C:\Users\ppiaggio\go\src\github.com\sap\gorfc\gorfc> echo $env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Go\bin;C:\Program Files\Git\cmd;C:\Users\ppiaggio\AppData\Local\Microsoft\WindowsApps;C:\Users\ppiaggio\go\bin;C:\Users\ppiaggio\win-build\bin;C:\Users\ppiaggio\win-build\bin;C:\Tools\nwrfcsdk\lib\

PS C:\Users\ppiaggio\go\src\github.com\sap\gorfc\gorfc> echo $env:SAPNWRFC_HOME
C:\Tools\nwrfcsdk

NetWeaver installation:

PS C:\Users\ppiaggio\go\src\github.com\sap\gorfc\gorfc> ls $env:SAPNWRFC_HOME


    Directory: C:\Tools\nwrfcsdk


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       10/10/2019   4:58 AM                bin
d-----       10/10/2019   4:58 AM                demo
d-----       10/10/2019   4:58 AM                doc
d-----       10/10/2019   4:58 AM                include
d-----       10/10/2019   4:58 AM                lib

How to add the tables parameter

In changes v0.1.0 says - Table parameter accepts also array of variables. Because this method #17 now work, I'm trying to put an array of variables
params := map[string]interface{}{ "ATHDRLEVELS": []string{"000001000825"} } r, _ := c.Call("Z_IEXT_PRODORDCONF_CREATE_HDR", params)

This parameter is substituted only for the ORDERID field. Could you explain how to use an array of variables in the tables parameter. Thanks.

RFC result incomplete for Chinese character

I wrote a script to read production order detail and have a problem .

The component material description is a unicode string like "壹贰叁肆伍陆柒捌玖拾一二三四五六七八九十1234567890".
The length of the material description is 30 when it is Unicode.
But when i call the script below, the result show "壹贰叁肆伍陆柒捌玖拾一二三�".
The result was incomplete.
When i use pyrfc,the result was complete.

After some testing I have found the length of "MATERIAL DESCRIPTION" field of "COMPONENT" table in BAPI_PRODORD_GET_DETAIL is 40 char.
While the length of the material description i haved used is 70 when it is UTF8.

I realize the problem may be caused by the utf8,but i don't know how to fixed it.
Any help or advice would be really appreciated. Thank you.

I am using Ubuntu 17.04 64bit.

The code i have used is below:

func main() {
	params := map[string]interface{}{
		"NUMBER": "800000039964",
		"ORDER_OBJECTS": map[string]interface{}{
			"COMPONENTS": "X",
		},
	}
	c, err := gorfc.ConnectionFromParams(abapSystem())
	checkErr(err)

	defer c.Close()
	result, err := c.Call("BAPI_PRODORD_GET_DETAIL", params)
	checkErr(err)
	for tableName, table := range result {
		if tableName == "COMPONENT" {
			for _, row := range table.([]interface{}) {
				rowMap := row.(map[string]interface{})
				if rowMap["DELETION_INDICATOR"] != "X" {
					fmt.Println(rowMap["MATERIAL_DESCRIPTION"].(string))
				}
			}
		}
	}
}

Memory access error on Windows, if free in nWrapString enabled

Memory access error occurs on Windows only, when trying to free RFCCHAR1 of RFCTABLE in function call test. As a workaround, the line 281 is commented (no malloc free!) and the usage on Windows is still experimental. Should be hopefully fixed by proper compiler switches combination.

Uncomment on Linux.

Error running hello_gorfc.go on CentOS 7

I having error running hello_gorfc.go

Connected: true
Connection attributes map[client:900� codepage:4103 cpicConvId:45417549 dest: host:my_host isoLanguage:RUd� kernelRel:753 language:R partnerBytesPerChar:2k partnerCodepage:4103 partnerHost:sap-host partnerIP:10.170.32.32 partnerIPv6:10.170.32.32 partnerRel:740 partnerSystemCodepage:4103 partnerType:3k progName:SAPLSYST rel:753 rfcRole:Ck sysId:CHQ sysNumber:10d� trace:0k type:Ek user:MYUSER] 
GORFC error: Error parsing ABAP RFC_DATE field | parsing time "20201124CTv�": extra text: "CTv�"

There is a wrong symbols added after some fields, for ex: isoLanguage:RUd�, sysNumber:10d�, trace:0k type:Ek
CentOS Linux release 7.9.2009 (Core)
go version go1.15.5 linux/amd64
nwrfc750P_7-70002752
Tryed on two different CentOS 7 and had the same errors.

The same settings from Ubuntu returns correct result:

Connected: true
Connection attributes map[client:900 codepage:4103 cpicConvId:45229127 dest: host:my_host isoLanguage:RU kernelRel:753 language:R partnerBytesPerChar:2 partnerCodepage:4103 partnerHost::sap-host partnerIP:10.170.32.32 partnerIPv6:10.170.32.32 partnerRel:740 partnerSystemCodepage:4103 partnerType:3 progName:SAPLSYST rel:753 rfcRole:C sysId:CHQ sysNumber:10 trace:0 type:E user:MYUSER]
map[RFCCHAR1:A RFCCHAR2:BC RFCCHAR4:ÄBC RFCDATA1:HELLÖ SÄP RFCDATA2:DATA222 RFCDATE:2020-11-24 00:00:00 +0000 UTC RFCFLOAT:1.23456789 RFCHEX3:[255 254 253] RFCINT1:254 RFCINT2:32766 RFCINT4:999999999 RFCTIME:0000-01-01 12:37:33 +0000 UTC]
map[RFCCHAR1:A RFCCHAR2:BC RFCCHAR4:ÄBC RFCDATA1:HELLÖ SÄP RFCDATA2:DATA222 RFCDATE:2020-11-24 00:00:00 +0000 UTC RFCFLOAT:1.23456789 RFCHEX3:[255 254 253] RFCINT1:254 RFCINT2:32766 RFCINT4:999999999 RFCTIME:0000-01-01 12:37:33 +0000 UTC]
2020-11-24 12:37:33.8180975 +0300 MSK m=+0.378176001 time.Time
2020-11-24 00:00:00 +0000 UTC time.Time
2020-11-24 12:37:33.818092 +0300 MSK m=+0.378171001 time.Time
0000-01-01 12:37:33 +0000 UTC time.Time

What should I additionally check for run gorfc on CentOS 7? Has anyone successfully run gorfc on CentOS 7?

Register destinations

I am coming from JCo and I was used to register the connection parameters with a name to the JCo.
I saw that the gorfc lib is offering a ConnectionFromDest function, that sounds like what I would like to do.

But it's not clear to me, when or how the connection parameters are loaded.
Is this done automatically through the NWRFCSDK when the files are stored in a particular directory?

Archive the project

I was hitting an error and searching through the issues and saw that all issues are closed due sunset of the project.

Is this project dead? If it is so, then please archive the project to make this clear, so no one sets on this project anymore ...

gorfc programs do not work with executables generated in go 1.15 (for windows-64 10)

Do you know something about this issue?
Go programs contaning gorfc package compile without error under 1.15, but when executing, no output is generated. When I compile with 1.14 it compiles without errors and the output is what I expected.
The same problem happens when compiling and executing program "hello_gorfc.go".
Best regards.

how to decode the RFC_BYTE data ?

hello guys:
I am getting fields with type of []bytes when the actual data type in ABAP in RAW byte, and using string() function could not make it a readable format. sometime it become "garbled". And the most funny thing is that when I expecting two returns should be different, but the return bytes is exactly the same.

putting my code as below. I am trying to decode the tasktype. Thanks in advance in case you have any ideas.

========================================
package main

import (
"fmt"
"time"
"encoding/base64"
"github.com/sap/gorfc/gorfc"
)

func abapSystem() gorfc.ConnectionParameter {
return gorfc.ConnectionParameter{
Client: "000",
User: "ddic",
Passwd: "",
Lang: "EN",
Ashost: "",

	Sysnr:     "00",
}

}

func main() {
c, err := gorfc.ConnectionFromParams(abapSystem())

if err != nil{
	fmt.Println(err)
} else{
	fmt.Println("ok")
}
defer c.Close()


end_datetime    := time.Now()
d, _ := time.ParseDuration("10m")
start_datetime  := end_datetime.Add( -d )

r, err := c.Call("SWNC_GET_STATRECS_FRAME", 
		map[string]interface{}{
				"READ_START_DATE": start_datetime,
				"READ_START_TIME": start_datetime,
				"READ_END_DATE": end_datetime,
				"READ_END_TIME": end_datetime,
				// "TASKTYPES_PER_WORKPROCESS": "X",
		   },

		)
if err != nil {
    // err
} else {
    all_recs := r["ALL_STATRECS"].([]interface{})
    for _, recs := range all_recs {
        rec  := recs.(map[string]interface{})
        statrecs := rec["STATRECS"].([]interface{})

        // fmt.Println(statrecs)

        for _, statrec := range statrecs {
            stat  := statrec.(map[string]interface{})
            mainrec := stat["MAINREC"].(map[string]interface{})
            r_datetime :=  mainrec["STARTDATE"].(time.Time).Format("2006-01-02") +" "+ mainrec["STARTTIME"].(time.Time).Format("15:04:05")
            // fmt.Println(mainrec)
            fmt.Println("=======")
            fmt.Println(r_datetime)
            // t1 := hex.EncodeToString( mainrec["TASKTYPE"].([]byte) )
            // t2, _ := hex.DecodeString( t1 )
            // t3 := fmt.Sprintf("%s", t2) 

            input := mainrec["TASKTYPE"].([]byte)

			fmt.Println(input)
			// 演示base64编码
			encodeString := base64.StdEncoding.EncodeToString(input)
			fmt.Println(encodeString)
		
			// 对上面的编码结果进行base64解码
			decodeBytes, err := base64.StdEncoding.DecodeString(encodeString)
			if err != nil {
			    // log.Fatalln(err)
			    fmt.Println(err)
			}
			fmt.Println(string(decodeBytes))
            fmt.Println(mainrec["TASKTYPE"].([]byte))
            // fmt.Println(mainrec["ACCOUNT"].(string))
            // fmt.Println(mainrec["REPORT"].(string))
            // fmt.Println(mainrec["TCODE"].(string))
            // fmt.Println(mainrec["ENTRY_ID"].(string))
            fmt.Println("=======")
            
        }
	}
}

}

Error on go build step

hi,
when follow the Doc to build the gorfc, get an error message
C:\Gops\src\github.com\sap\gorfc\gorfc>go build #github.com/sap/gorfc/gorfc In file included from C:/nwrfcsdk/include/sapnwrfc.h:7:0, from .\gorfc.go:41: C:/nwrfcsdk/include/sapucx.h:562:5: warning: 'align' attribute directive ignored [-Wattributes] typedef __declspec(align(16)) SAP_SRAW platform_max_t[16]; ^ In file included from .\gorfc.go:41:0: C:/nwrfcsdk/include/sapnwrfc.h:28:0: warning: ignoring #pragma warning [-Wunknown-pragmas] #pragma warning (disable : 4267) // disable warning: conversion from 'size_t' to 'const unsigned int' ^ In file included from C:/nwrfcsdk/include/sapnwrfc.h:9:0, from .\gorfc.go:41: C:/nwrfcsdk/include/sapuc.h:853:24: warning: 'sccsidU16' defined but not used [-Wunused-variable] static const SAP_UC* sccsidU16 = NULL; ^
plantform

  • os windows 10
  • go 1.8

thanks for any help.

CGO (compiler) error in linux

Dear sap engineers:

I'm an experienced LinuxOS developer,I know something about gcc compiler and dynamic libraries call.
But now,CGO compiler throw error like this picture .

Thanks very much , sir.
Louis ,Shenzhen.

深度截图_选择区域_20190402152718

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.