I've downloaded SAP GUI for Windows 7.70 (latest version with 64bits connectors) and created an RFC function called Z_GF_STOCK
with a material string import parameter (ARTICULO
) and labst
export parameter (STOCK
).
I need to use this RFC with Excel with VBA with this code:
Dim retcd As Boolean
Dim SilentLogon As Boolean
Set logonControl = CreateObject("SAP.LogonControl.1")
Set objBAPIControl = CreateObject("SAP.Functions")
Set R3Connection = logonControl.NewConnection
R3Connection.Client = "100"
R3Connection.ApplicationServer = "192.168.XXX.XXX"
R3Connection.Language = "XX"
R3Connection.User = "XXXXX"
R3Connection.Password = "XXXXX"
R3Connection.System = "XXX"
R3Connection.SystemNumber = "XX"
R3Connection.UseSAPLogonIni = False
retcd = R3Connection.Logon(0, True)
objBAPIControl.Connection = R3Connection
Set objgetaddress = objBAPIControl.Add("Z_GF_STOCK")
objgetaddress.exports("ARTICULO") = "XXXXXX"
returnFunc = objgetaddress.Call
If returnFunc = True Then
ActiveCell.Value = objgetaddress.imports("STOCK")
objBAPIControl.Connection.Logoff
R3Connection.Logoff
Else
MsgBox "Error call Z_GF_STOCK! "
End If
objBAPIControl.Connection.Logoff
R3Connection.Logoff
R3Connection.Logoff
The returnFunc
variable is always false and never raises the line to get the value.