With help of VBA macros the logon to the backend system can be automated by using the standard VBA functionality which is supplied with BExAnalyzer for doing such a task. In order to automate the logon to the backend system the BExAnalyzer Addin must be loaded within Excel. The following VBA code sample shows how to create an RFC connection for the BEx Analyzer without bringing up the logon dialog. This Page describes how a connection can be established to the server using the Connection Object of BExAnalyzer. The information mentioned below is also explained in note 1843874, 1692573, 492561.
Please read note 2179529 for detail information.
The use of unicode instance "SAP.Functions.Unicode" will result in an error, as BexAnalyzer is a Non-Unicode application. BexAnalyzer always tries to access Non-Unicode instance of Logon/Function Control. Hence please use non-unicode instance i.e., "SAP.Functions" irrespective of the R3 system being unicode/non-unicode.
To establish a connection to the BW server following mandatory information must be supplied to the Connection Object:
System | ConnectionObject.system = "<system>" |
---|
System Number | ConnectionObject.systemnumber = <number> |
Application Server/SAPRouter | ConnectionObject.ApplicationServer = <applicationServer> |
| ConnectionObject.SAProuter = <SAPRouter> |
Client | ConnectionObject.client = "<client>" |
Language | ConnectionObject.Language = "<language>" |
User | ConnectionObject.user = "<user>" |
Password/SNC Information | ConnectionObject.Password = "<password>" |
| ConnectionObject.SNC = True |
| ConnectionObject.SNCName = "<SNCName>" |
| ConnectionObject.SNCQuality = <SNCQuality> |
Example 1:
Function LogonToServer() As Boolean
LogonToServer = False
Dim myConnection As Object
Set myConnection = Run("BExAnalyzer.xla!SAPBEXgetConnection")
With myConnection
.client = "000"
.user = "myUserName"
.Password = "myPassword"
.Language = "EN"
.systemnumber = 45
.system = "XXX"
.ApplicationServer = "ab1234.wdf.sap.corp"
.SAProuter = ""
.logon 0, True
End With
If myConnection.IsConnected <> 1 Then
'launch the Logon Dialog for manual connection
myConnection.logon 0, False
If myConnection.IsConnected <> 1 Then
MsgBox "something went wrong ..."
Exit Function
End If
End If
If myConnection.IsConnected = 1 Then
LogonToServer = True
End If
Run "BExAnalyzer.xla!SAPBEXinitConnection"
End Function
Example 2:
Function LogonToServer() As Boolean
LogonToServer = False
Dim myConnection As Object
Set myConnection = Run("BExAnalyzer.xla!SAPBEXgetConnection")
With myConnection
.client = "000"
.user = "myUserName"
.Password = ""
.Language = "EN"
.systemnumber = 45
.system = "XXX"
.ApplicationServer = "ab1234.wdf.sap.corp"
.SAProuter = ""
.SNC = True
.SNCName = "p:CN=XXX, O=SAP-AG, C=EN"
.SNCQuality = 9
.logon 0, True
End With
If myConnection.IsConnected <> 1 Then
'launch the Logon Dialog for manual connection
myConnection.logon 0, False
If myConnection.IsConnected <> 1 Then
MsgBox "something went wrong ..."
Exit Function
End If
End If
If myConnection.IsConnected = 1 Then
LogonToServer = True
End If
Run "BExAnalyzer.xla!SAPBEXinitConnection"
End Function
Example 3:
Synchronize BExAnalyzer Connection with SAP.Functions: Ensure that the SAPFunctions.Connection Variable has been defined globally Public.
(For SAP GUI 7.50 the object "SAPBEXgetConnection" is not providing a password anymore. This example is still working fine for SAP GUI 7.50 when using SSO,)
Public SAPFunctions As Object
Function connectToSAPFunctions() As Boolean
connectToSAPFunctions = False
Dim myConnection As Object
Set myConnection = Run("BExAnalyzer.xla!SAPBEXgetConnection")
If SAPFunctions Is Nothing Then
Set SAPFunctions = CreateObject("SAP.Functions")
End If
If SAPFunctions.Connection.IsConnected <> 1 Then
With SAPFunctions.Connection
.RfcWithDialog = myConnection.RfcWithDialog
.client = myConnection.client
.user = myConnection.user
.Password = myConnection.Password 'Only working with SAP GUI 7.40 and older
.Language = myConnection.Language
.systemnumber = myConnection.systemnumber
.system = myConnection.system
.ApplicationServer = myConnection.ApplicationServer
.MessageServer = myConnection.MessageServer
.SAProuter = myConnection.SAProuter
.SNC = myConnection.SNC
.SNCName = myConnection.SNCName
.SNCQuality = myConnection.SNCQuality
.Ticket = myConnection.Ticket
.Destination = myConnection.Destination
.HostName = myConnection.HostName
.GatewayHost = myConnection.GatewayHost
.GatewayService = myConnection.GatewayService
.logon 0, True
End With
If SAPFunctions.Connection.IsConnected <> 1 Then
MsgBox "something went wrong ..."
Exit Function
Else
MsgBox "Success"
End If
Else
MsgBox "SAPFunctions is still connected"
End If
connectToSAPFunctions = True
End Function
8 Comments
Deepak Kumar Shah
All below mentioned parameter are related to connection “FROM” BWserver “TO” bexanaylzer when transaction RRMX or RRMXP is used.
ANA_RRMXP_HOST, ANA_RRMX_USE_XML, RRMX_USE_TICKET
sapBEXgetConnection is used when trying to connect “FROM” Bexanylazer “TO” BWserver.
Further sapBEXgetConnection will not have any effect with Unicode/Non-Unicode.
Former Member
Hi Deepak, We have been using this functionality for a few years now with SAPGUI 720 but we have recently tried to upgrade to SAPGUI 730 but have found this logon function using an ID & PW has stopped working, what is strange is the code above doesn't work for us when it is first run however if we change ' .logon 0', True to ' .logon 0, False' so that the connection dialogue box loads and click ok without changing any credentials then it connects. Interestingly if I then disconnect then run the code below in the same session it will connect?, Have you seen any issues with using this code with SAPGUI 7 3
Many Thanks Deepak
Alex
Former Member
Hi ALex,
i am also trying to automate BEX and BW using VBA but dialogue box also pop up....
Do you have any idea how to Silent Logon to BW using VBA.
Thanks in Advance.
Regards,
Atul
Former Member
Hi Atul,
We did not manage to fix this so we have kept the team who need to use it on the old SAPGUI and just upgraded the rest of the firm, I looked for ages and didnt find any more detail to help on this issue than the what is on this page.
Many Thanks
Alex
Former Member
Hi Alex,
use the below may this will help you-
https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui_entry/entry.htm?param=69765F6D6F64653D3030312669765F7361706E6F7465735F6E756D6265723D3231373935323926
Sergey Musatov
Hi Deepak,
can you please give me advice how to call RFC function module from BEx in SAP GUI 7.50 in absolutely silent mode (without logon dialog) using current BEx connection session parameters? In SAP GUI 7.40 we used the way described in example 3. But now in GUI 7.50 all three methods mentioned above do not work as it is required.
Vinoth Vasudevan
Hello Sergey Musatov, Deepak Kumar Shah
I am experiencing the same issue since I upgraded my GUI to 7.50
Were you able to get this resolved? If so, could you please share details on what has been done. Here is the thread I had raised in SCN.
https://answers.sap.com/questions/12917870/unable-to-login-into-bex-in-silent-mode-since-sap.html
Thanks.
Sergey Musatov
Hello Vinoth Vasudevan,
first of all, please try SAP note 2541995 - BEx Analyzer: Using VBA to connect to BW server with SAPBEXgetConnection , where you can find code snippet attached.
When LandscapeFormatEnabled parameter is enabled (in SAP Logon options), you have to provide "MSHOST plus SYSID and GROUP" for silent logon, as below :
.MessageServer = objCon.MessageServer
.GroupName = objCon.GroupName