cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic Logon to BEx

Former Member
0 Kudos

Hi Guru's

Can any one solve my problem that i have created workbook and send it to user now user dont like to open workbook and then open bex tool bar and go for refresh. So by uisng VBA we can write code for Automatic logon i.e when opening the workbook it will automatically opens the BEx tool bar so it is more useful for users.

Please anybady across this type of problems send me the code and steps.

Thanks in Advance...

Jagadeesh.M

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Functions 1 and 2 can be combined along with the following code to establish a connection with the server:

Public Function LogonToYourBW()

' create Logon & RFC-Handle

logonToBW = False ‘ clear connect Flag the flag can be used to find out if connected or not

'load SAP functionality by opening BEX file ( use your installation path)

Workbooks.Open (“c:\sappc\bw\sapbex.xla”)

With Run("sapbex.xla!sapbexGetConnection") ‘ call the connection

' Set the params for Auto logon

.client = “YOUR CLIENT NO”

.user = “YOUR BW USER”

.Password = “YOUR BW PWD” ‘ I recommend to create a dummy reporting user for this task

.Language = “YOUR LANGUAGE YOU LIKE TO USE FOR QUERY DISPLAY ( i.E. “EN”)”

.SystemNumber = “YOUR SYSTEM NO” ‘

.ApplicationServer = “YOUR SERVER Name OR IP-ADDRESS”

.UseSAPLOgonIni = FALSE 'important for automatic connection

.logon 0, True ‘ This will provide a dialog to appear

If .IsConnected <> 1 Then

.logon 0, False

If .IsConnected <> 1 Then Exit Function

Else

Set g_oFunction = CreateObject("SAP.Functions")

Set g_oFunction.Connection = g_oConnection

End If

End With

Run "sapbex.xla!sapbexinitConnection" ‘ this will enable the connection you just created

logonToBW = True

End Function

Function 7 can be used to refresh queries in an active workbook. To refresh all queries, set the first parameter to True and use the following code:

If Run("sapbex.xla!SAPBEXrefresh", True) = 0 Then

Else

MsgBox " Error in Refresh"

To refresh a single query, reference a valid cell in the query (navigation or filter area or result area)

‘Set the values for Variables

Dim rngVar as Range

Set rngVar = YOUR_VARIABLE_SHEET.Range(“A2:H3”)

Run "SAPBEXsetVariables", rngVar

If Run("SAPBEX.xla!SAPBEXrefresh", False, ActiveSheet.Range("C7")) = 0 Then

Else

MsgBox "Error in Refresh”

End If

REgards,

San!

Former Member
0 Kudos

Hi

I already have that code but where i have to insert that and how can i proceed give me those steps i will give more points for u...thanks

Jagadeesh.M

Former Member
0 Kudos

Hi,

/people/sap.user72/blog/2006/06/05/long-texts-in-sap-bw-displaying-in-bex-analyzer-introduction-to-excel-workbooks-formatting-part-i

and

/people/sap.user72/blog/2006/06/05/long-texts-in-sap-bw-displaying-in-bex-analyzer-introduction-to-excel-workbooks-formatting-part-ii

Regards,

San!

Where are my points dude?

Message was edited by:

Sandeep Khatri

Former Member
0 Kudos

Hey,

I'm relatively new to this so please excuse my lack of knowledge.

I tried to implement the above code, but when I run the function, the SAP Logon screen still pops up.  I'm not positive that my applicationserver and systemnumber parameters are correct  - could this be the cause? 

Username and password parameters are successfully passed.

Thanks,

Chris