This website is not affiliated with, sponsored by, or approved by SAP AG.

Connecting to the BW server via VBA ( NOTE 0492561 )

Business Warehouse

Moderators: thx4allthefish, Snowy

Connecting to the BW server via VBA ( NOTE 0492561 )

Postby Guest » Mon Oct 21, 2002 7:16 am

Hello ,

I'm trying to use note 492561 in order to connect to the BW server via VBA. When I implement the following code :

Sub Logon_to_server()

logontoBW = False
On Error GoTo leave
Dim MyConnection As Object
Set MyConnection = Run("SAPBEX.XLA!SAPBEXgetConnection")

With MyConnection
.client = "100"
.user = "TESTUSER"
.password = "12345"
.Language = "NL"
.Systemid = "BWD"
.SAPROUTER = ""
.systemnumber = "00"
.system = "BWP"
.ApplicationServer = "ZD01"
.logon 0, True

If .isConnected <> 0 Then
.logon 0, False
If .isConnected <> 1 Then
MsgBox "Something went wrong"
Exit Sub
End If
End If

End With
Run "SAPBEX.XLA!SAPBEXInitConnection"
logontoBW = True

exit sub
leave:
MsgBox Err.Description

End Sub


the connection fails and .isConnected <> 0

If .isConnected <> 0 Then
.logon 0, False

The next code ".logon 0, False" will triger the normal logon screen in the BexAnalyser and when i press enter ( OK ) , I will logon to the system normally with the settings I have provided in the vba code.

Does anyone know why I can't logon with .logon 0,True ???
( This code is used to logon to the system without the popupscreen. )

Thanx in Advance ...
Hans

Guest
 

Postby hellasangel » Tue Oct 22, 2002 4:58 am

Hi Hans:

I have tried to run this macro too however it fails in this command:

Set MyConnection = Run("SAPBEX.XLA!SAPBEXgetConnection")

It cannot find the macro SAPBEXgetConnection in the sapbex.xla.

I have tried to open sapbex.xla for editing to see the macro however it requires a password. Does anybody know this password? Is it anywhere available in SAPNet? If it were I would be able to help you more with that.

Regards


Angelo
Angelos Chatzigiannakis
SAP Consultant/BW
Athens Greece
Tel: +44 7700 024024
Email: angel ΑΤ economist.net
hellasangel
 
Posts: 81
Joined: Mon Oct 21, 2002 5:07 am
Location: Greece

Postby Guest » Tue Oct 22, 2002 9:30 am

Check out the addtional documentation available in 3.0b on all the VBA functionality. Here are additional comments from SAP on using BEX
connect:

function sapBEXgetConnection(Optional what As Integer) As Variant
This function will return the connection already used. If you are not
connected to a System this function will show the logon popup. It is
not possible with this function to automate a logon.
the parameter what is optional. If you set what = 1 you will get the
username connected to the system what = 2 will give you the systemnr.
the default return is the whole Connection Object as Object
the Username is string and systemnr is as integer which formatting 00


Function sapBEXinitConnection(Optional newConnectionObj As Object)
as boolean
This function will only fill Global Variables with current system
settings. You will not use this function normally.


We've tried the approach in the OSS note you've mentione d and it works a treat.

MM
Guest
 

Postby hellasangel » Wed Oct 30, 2002 7:07 am

Hi again:

First of all there is an error in your code. In order to make it work change:

If .isConnected <> 0 Then
.logon 0, False

to

If .isConnected = 0 Then
.logon 0, False

With this small correction the code you mentioned logs me in without going through the log on screen.

What will happen when you make this change in the code is the following:

a) You will connect so MyConnection.IsConnected will be 1 and you can write your code afterwards.

b) You will get a message "Something went wrong" which means that MyConnection.IsConnected is neither 0 (not connected) nor 1 (connected). It will be something like 3,4,5 etc which means that there is an error in the values that you provided before. I will give you the values I have used so you can change your values accordingly:

.client = "120"
.user = "achatzigiann"
.Password = "12345"
.Language = "EN"
.Systemid = "SAP BW" (just leave this like that)
.SAPROUTER = ""
.systemnumber = "10"
.system = "BD1" (this is probably your BWD)
.ApplicationServer = "SAPBW" (this is the computer name where BW is)

If you get again an error message answer to that and I will be able to help you.

Regards


Angelo
-
Angelos Chatzigiannakis
SAP Consultant/BW
Athens Greece
Tel: +44 7700 024024
Email: angel ΑΤ economist.net
hellasangel
 
Posts: 81
Joined: Mon Oct 21, 2002 5:07 am
Location: Greece


Return to Business Warehouse

Who is online

Users browsing this forum: No registered users and 7 guests




This website is not affiliated with, sponsored by, or approved by SAP AG.