Connecting via VBA to a SAP system

If you want to create automated reports with data from an SAP ERP or Business Warehouse system, you first need to connect to a SAP system. The connection can be used later to access system tables in the ERP or Business Warehouse or to trigger various other action.

Function Connect_to_SAP()

Dim myConnection As Object

Set myConnection = CreateObject("SAP.Functions")

With myConnection

.Connection.System = "ABC" 'Systemname

.Connection.client = "100" 'Client

.Connection.user = "xyz" 'User

.Connection.password = "123" 'Password

.Connection.Language = "DE" 'Language

.Connection.systemnumber = "00" 'Systemnumber

.Connection.hostname = "" 'Hostname

End With

'Establish connection.

If myConnection.Connection.logon(0, False) <> True Then Exit Function

'System Logoff

myConnection.Connection.LOGOFF

End Function

Due to the parameters False in the connection following Logon screen appears. Should this not be displayed, the parameter must be changed from False to True.

Logon via VBA
Logon via VBA

author.


I am Tobias, I write this blog since 2014, you can find me on twitter and youtube. If you want you can leave me a paypal coffee donation. You can also contact me directly if you want.

Analysis Office - The Comprehensive Guide 3rd edit
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.6 and contains 272 Pages.
49,99 €
Analysis Office - The Comprehensive Guide 2nd edit
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.4 and contains 243 pages.
39,99 €
Analysis Office - The Comprehensive Guide
Analysis Office - The Comprehensive Guide is a pdf book about SAP BusinessObjects Analysis Office. It is based on Analysis Office 2.3 and contains 227 Pages.
9,99 €

Write a comment

Comments: 0