Procedure
To run the following example, create a new Visual Basic project by following these steps:
Code
Option Explicit
Private moRepObj As Object
Private moLogonObj As Object
Dim moConn As Object
Private Sub cmdBrowse_Click()
Dim oAppHiers As Object
Dim oAppHier As Object
Set moRepObj = CreateObject("SAP.RepositoryServicesonline.1")
If moRepObj Is Nothing Then
MsgBox "Could not create Repository object", vbInformation
Exit Sub
End If
Set moLogonObj = CreateObject("SAP.LogonControl.1")
If Not moLogonObj Is Nothing Then
Set moConn = moLogonObj.NewConnection
If Not moConn Is Nothing Then moConn.Logon
Else
MsgBox "Could not create logon object", vbInformation
Exit Sub
End If
moRepObj.Connection = moConn
SAPBrowse1.EnableBAPITab True
Set oAppHiers = moRepObj.ApplicationHierarchies()
If SAPBrowse1.Connect(moRepObj) Then
For Each oAppHier In oAppHiers
SAPBrowse1.AddBAPIAppObject oAppHier
Next
End If
End Sub
Private Sub cmdProperty()
SAPBrowse1.ShowPropertyWindow Me.Hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
moConn.Logoff
End Sub