Ejemplo n.º 1
0
func main() {
	//select * from
	arg.String("table", "USR01", "read from table", time.Second*55)
	arg.String("dest", "", "destination system", time.Second*55)
	arg.String("client", "", "client", time.Second*55)
	arg.String("user", "RFC", "username", time.Second*55)
	arg.String("pass", "", "password", time.Second*55)
	arg.String("lang", "DE", "language", time.Second*55)
	arg.String("host", "127.0.0.1", "SAP server", time.Second*55)
	arg.String("sysnr", "00", "SysNr", time.Second*5)
	arg.String("router", "/H/127.0.0.1/H/", "SAP router", time.Second*55)
	arg.Parse()

	SAPconnection, _ = saprfc.ConnectionFromParams(saprfc.ConnectionParameter{
		Dest:      arg.Get("dest").(string),
		Client:    arg.Get("client").(string),
		User:      arg.Get("user").(string),
		Passwd:    arg.Get("pass").(string),
		Lang:      arg.Get("lang").(string),
		Ashost:    arg.Get("host").(string),
		Sysnr:     arg.Get("sysnr").(string),
		Saprouter: arg.Get("router").(string),
	})

	printTable(arg.Get("table").(string))

	SAPconnection.Close()
}
Ejemplo n.º 2
0
func main() {
	c, _ := saprfc.ConnectionFromParams(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("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"]))

	c.Close()
}
Ejemplo n.º 3
0
func connect() error {
	var err error
	SAPconnection, err = saprfc.ConnectionFromParams(abapSystem())
	return err
}