04-13-2016 5:31 PM
Hello,
I am trying to retrieve data from a transaction code in SAP using VBA in MS Excel. I understand that there is one way of doing this using SAP GUI scripting but is there another way using Remote Function Calls?
I was looking at RFC_CALL_TRANSACTION and RFC_CALL_TRANSACTION_USING. Does this accomplish what I need? For example, I have a transaction code called "TCODE" and I need to pass some arguments in such as a date range to generate data. Can I use RFC's or should I stick to GUI scripting?
So far, I can connect to SAP and retrieve specific table information but how can I execute a transaction code while passing in parameters.
Set obSAPFnCntrl = CreateObject("SAP.Functions")
Set obSAPConn = obSAPFnCntrl.Connection
With obSAPConn
.System = "system"
.User = "user"
.Password = ""
.Language = "EN"
.Client = 750
End With
Set obSAPFnUserDetail = obSAPFnCntrl.Add("RFC_CALL_TRANSACTION")
'Set obSAPFnUserDetail = obSAPFnCntrl.Add("BAPI_USER_GET_DETAIL")
Thanks in advance!
04-14-2016 2:11 PM
You can use this method to get data out of SAP, only if the function module returns it as a parameter.
For eg. BAPI_USER_GET_DETAIL has some return parameters, which will give you back user details. But, RFC_CALL_TRANSACTION isn't for meant for returning any data from SAP.
We may be able to better assist you if you can tell the Tcode, which you are trying to access.
Thanks,
Juwin
04-14-2016 7:05 PM
Hello,
Thanks for your reply Juwin. The transaction code that I am trying to access is CADO which displays time sheet data. I experimented with SAP GUI scripting but that won't work for me because I need to pass in a date range, personnel numbers and a layout before generating the excel spreadsheet. Any help is appreciated. Thanks!
04-14-2016 9:26 PM
Unfortunately, I don't have any data for that in my system which would allow me to dig further.
I assume you are not a ABAPer, looking at your question. Am I right?
If so, do you have any ABAPers in your organization who can help you?
Thanks,
Juwin
04-14-2016 10:22 PM
Hi,
You can to use this BAPI: BAPI_EECATIMESHEET_GETWORKLIST. This BAPI is a RFC.
First, you need knows the parameters.