Connect to SAP

joaompc

Registered User.
Local time
Today, 11:40
Joined
Sep 13, 2012
Messages
39
Hello!

Anyone has a code to open SAP from access?

I was using:

Set SAP = CreateObject("SAP.Functions")

But when i insert the user data it gives me an error:

Access 2010 SAPLOgon_ID 'SYSTEM' not found in saplogon.ini

Thanks,

JC
 
When using the F2 Object Browser from a code module, does the SAP Object, Properties and methods expose themselves?
 

Attachments

  • Object Browser References.png
    Object Browser References.png
    20.2 KB · Views: 675
Last edited:
This Is the code i am using.

Private Sub QServiceOrder_Click()
Dim SAP As Object
Dim conn As Object
Dim LogonControl
Dim funcControl
Dim TableFactoryCtrl
Dim RFC_READ_TABLE
Dim eQUERY_TAB
Dim tblOptions
Dim tblData
Dim tblFields
Dim retcd
Dim strExport1
Dim strExport2
Dim intRow As Integer
Dim StrMaterial As String
Dim objFileSystemObject As Object
Dim filOutput As Object

Set LogonControl = VBA.CreateObject("SAP.LogonControl.1")
Set funcControl = VBA.CreateObject("SAP.Functions")
Set conn = LogonControl.NewConnection

conn.System = "ENP"
conn.Client = "009"
conn.User = "USER"
conn.Password = "PASS"
conn.Language = "EN"
retcd = conn.LogOn(0, False)

Select Case retcd

Case False

VBA.MsgBox "Cannot Log On!", vbInformation + vbOKOnly, "Logon Failed"
Set LogonControl = Nothing
Set funControl = Nothing
Set conn = Nothing
Exit Sub

Case True

funcControl.Connection = conn[/INDENT]

The Logon form appears but nothing happens after. How Can I show SAP and search for a Order in a transaction for exemple?

Thank you
 
Rx_'s suggestion remains to be answered.

SAP is not a part of Access, thus in order to link over to it one must enable a reference in the Access DB to gain access to SAP. That us what Rx_ was asking.
 
Thanks, you are so correct. Just checking to see if the SAP is referenced.
Once it is referenced, then the Object Browser (F2) should expose more of the properties and methods. Had an inturruption and didn't have time to complete the post.
 
Which references should I add to Access to connect to SAP?

Thanks,

JC
 
http://klanguedoc.hubpages.com/hub/Silent-Connection-with-SAPLOGON-with-RFCSDK-Example-RFC-Excel-VBA
I don't have SAP, did some searching for you.
This site has step-by-step for connecting SAP to Excel VBA throught the Excel code module. The process for Access VBA should be very close to the same.

If it works or if you have modifications, please report back. There will probably be many others searching for this answer too.

Note that you need the SAP GUI ActiveX loaded as a reference in order to run this in VBA. (wdtfuncs.ocx)
http://www.mrexcel.com/forum/excel-questions/334930-macro-connects-sap.html
 
Last edited:

Users who are viewing this thread

Back
Top Bottom