Showing results for 
Search instead for 
Did you mean: 

Connection to SAPBobsCom

Former Member
0 Kudos

Hi All

I have created a VB.NET project that comprises of the following modules:

Connection Module - This module initiates the single sign-on connection. I have declared the following statement "Public oDICompany As SAPbobsCOM.Company" in my Global module.

After I initiate an event filter for form load on the Quotation, the oDICompany object looses the connection. The event filter triggers the form load the calls a function to populate a combo box.

If I call the function before the filter is initiated, then the following code works fine:

oRecordSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

sQuery = "Select empID,lastname from OHEM"


Please help.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi John,

Do you get an error message? If not, is your code (where you get the error - add event filter) in a try... catch block with a message to ensure you know if an error occurs?


Former Member
0 Kudos

Hi Adele

Error Number: 13 Description: QueryInterface SAPBobsCom.ICompany Failed

The app. falls over on the following statement:

oRecordSet = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

Thanks John

Former Member
0 Kudos

Are you sure that you get no other error that could break your connection to the DI before this line is executed? And also, is the event filter code in a try... catch block?

Former Member
0 Kudos

Their is no error because I step through the code and it goes through fine until it tries to get data from the db.

The event filter is a module. The following code is what I am using:

Module Test

Private WithEvents SBO_Application As SAPbouiCOM.Application

Public oFilters As SAPbouiCOM.EventFilters

Public oFilter As SAPbouiCOM.EventFilter

Private oOrderForm As SAPbouiCOM.Form

Private oRecordSet As SAPbobsCOM.Recordset

Public Sub SetFilters()

'// Create a new EventFilters object

oFilters = New SAPbouiCOM.EventFilters

'// add an event type to the container

'// this method returns an EventFilter object

oFilter = oFilters.Add(SAPbouiCOM.BoEventTypes.et_FORM_LOAD)

'// assign the form type on which the event would be processed

oFilter.Add("139") 'Sales Order Form

oFilter.Add("149") 'Sales Quotation

'// Initiate event filter

SBO_Application = SboGuiApi.GetApplication()


End Sub

Public Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

If pVal.FormType <> 0 Then

Select Case pVal.EventType

Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD

'// Specifies that SAP Business One application opened a form.

If pVal.FormType = "149" Then


End If

End Select

End If

End Sub

If I do not call the event filter and just call the Retrieve_Employees then it works fine.

Thanks John