I'm trying to call SAP functions from an Excel macro, VBA. I can do the connection, but whenever the code reaches the line that calls a function, I get the error message "Run-time error '61704': Internal application error.
My code is the following:
Dim functionCtrl As Object
Dim sapConnection As Object
Dim theFunc As Object
Dim PoNumber
Set functionCtrl = CreateObject("SAP.Functions")
Set sapConnection = functionCtrl.Connection
sapConnection.System = ""
sapConnection.Client = ""
sapConnection.user = ""
sapConnection.Password = ""
sapConnection.Language = ""
If sapConnection.logon(0, False) <> True Then
MsgBox "No connection to R/3 System"
Exit Sub 'End program
End If
Set theFunc = functionCtrl.Add("BAPI_REQUISITION_CREATE")
The error comes just when the last line is executed. I've added librfc32.dll in the references, I'm able to execute GUI scripts (recorded from SAP).
Does it have something to do with permissions or something?
Thanks
I would not answer exactly your question but I hope to provide useful info anyway. I currently work on migration of accounting data from QuickBooks to SAP. I used Ruby and Ruby on Rails for scripting and web interface.
Since you are comfortable with scripting let me recommend to try the following:
Installing Ruby and libraries is really simple.
You may need to create config file:
Then try something like this:
You may receive errors regarding GL accounts etc. but this is just my working example. What's important here is to get RFC connection established. Then you can move on to prepare
BAPI_REQUISITION_CREATE
call, fill incall.REQUISITION_ITEMS
, invoke it and checkcall.RETURN
.You may also find convenient that Ruby and Ruby on Rails can read data from Excel and integrate with different databases. This is working for me.
Cheers,
Alexei
To access SAP you will need at a minimun s_RFC. You need to get with your SAP admin section for this and to determine which other authority objects that you might (or might not) need.