Skip to Content
0
Former Member
May 05, 2004 at 12:37 PM

UI: Company Changed Event

31 Views

Hi all.

Can anyone provide me with an example on how to handle the Company Changed event?

What I do now is something like this (the SetApplication works when I connect in the first place):

Dim sConnectionString As String

Dim SboGuiApi As SAPbouiCOM.SboGuiApi

Private Sub con_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent

Select Case EventType

Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown

End

Case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged

vcmp = Nothing

SetApplication()

End Select

End Sub

Sub SetApplication()

Dim str as string

SboGuiApi.Connect(sConnectionString)

SBO_Application = SboGuiApi.GetApplication()

vcmp = New SAPbobsCOM.Company()

str = vcmp.GetContextCookie()

str = SBO_Application.Company.GetConnectionContext(str)

vcmp.SetSboLoginContext(str)

vcmp.Connect()

. . .

end Sub

The problem is, that I keep getting the CompanyChanged event. My guess is that it is because I reconnect to the application before the eventhandler has returned, but I can't really figure out how to do....

Any help appriciated.

Thanks in advance

Jesper Carstensen