-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathhello_gorfc.go
71 lines (59 loc) · 1.51 KB
/
hello_gorfc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"reflect"
"time"
"github.com/sap/gorfc/gorfc"
)
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, err := gorfc.ConnectionFromParams(abapSystem())
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Connected:", c.Alive())
attrs, _ := c.GetConnectionAttributes()
fmt.Println("Connection attributes", attrs)
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, e := c.Call("STFC_STRUCTURE", params)
if e != nil {
fmt.Println(e)
return
}
fmt.Println(r["ECHOSTRUCT"])
importStruct := params["IMPORTSTRUCT"].(map[string]interface{})
echoStruct := r["ECHOSTRUCT"].(map[string]interface{})
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()
}