Skip to Content
0
Aug 09, 2016 at 07:34 AM

Calling sap screen in non sap system via RFC FM in EXCEL

292 Views

Hi ,

There is a standard RFC FM "FUNC_LOCATION_RFC_002'' which is used display the sap screen of tcode IL03 with data on following input parameter (functional location, WITH_DIALOG_SCREEN =’X’and WAIT_AFTER_COMMIT = ‘X’). And it will display attached screen with data.

I have following requirement ( Calling sap screen in non sap system via RFC FM):-

1. Calling sap RFC FM “FUNC_LOCATION_RFC_002’’ from excel .

2. And this RFC FM should display sap screen of tcode IL03 on clicking button in excel i.e non sap system.

I am able to connect the sap system and set parameter of RFC FM , but it is falling while calling the RFC FM . at statements :- result = ObjR3Func.call in the below code Below is code in excel:-

Below is code in excel:-

Dim ObjR3

Set ObjR3 = CreateObject("SAP.Functions")

'--parameter to abap object

Dim ObjPrm1

Dim ObjPrm2

Dim ObjPrm3

'--parameter from abap (return) object

Dim ObjParmin

'--abap function to use object

Dim ObjR3Func

'--return code for abap call

Dim result

'--abap table returned object

Dim Objudextab

Set ObjR3Func = CreateObject("SAP.Functions")

ObjR3Func.Connection.RfcWithDialog = True

'--get this info from your logon pad..

ObjR3.Connection.System = "XDE"

ObjR3.Connection.Client = "200"

ObjR3.Connection.User = "XXXX"

ObjR3.Connection.Password = "XXXXXXX"

ObjR3.Connection.Language = "EN"

ObjR3.Connection.ApplicationServer = "XXXXXXXX"

ObjR3.Connection.SystemNumber = "00"

'--if no logon then exit

If ObjR3.Connection.logon(0, True) <> True Then

WScript.Echo "Sap connection error - " & ObjR3.Connection.User & " - " & ObjR3.Connection.System

WScript.Quit

End If

'--address the set abap function

Set ObjR3Func = ObjR3.Add("FUNC_LOCATION_RFC_002")

'--and the paramters we will send

Set ObjPrm1 = ObjR3Func.exports("FUNC_LOCATION")

Set ObjPrm2 = ObjR3Func.exports("WITH_DIALOG_SCREEN")

Set ObjPrm3 = ObjR3Func.exports("WAIT_AFTER_COMMIT")

'--and values

ObjPrm1.Value = "value1"

ObjPrm2.Value = "X"

ObjPrm3.Value = "X"

'--do it

result = ObjR3Func.call

'--if ok then process - else exit

If result = False Then

'-----if it was stuffed the exit

WScript.Echo "Error reading sap - " & ObjR3.Connection.User & " - " & ObjR3.Connection.System

ObjR3.Connection.LOGOFF

WScript.Quit

Else

Set Objudextab = ObjR3Func.Tables("COSTCENTER_LIST")

End If


Attachments

test.jpg (123.5 kB)