Skip to Content
author's profile photo Former Member
Former Member

Application_ItemEvent () and DI objects ------ VB.NET

Hi friends ,

i've a strange problem.I use VB.NET

I declare and instance any DI object variables like "Company","Business Partners" and others.

While in normal procedures their values are recognized,in the Application_ItemEvent() and called functions they seem to lose their value...

My tool recognizes with (intellisense)the object, but in the runtime it seems not regognize the object....a little example :

I make an instance of a new company variable.

I set the properties and then connect it.

It works well until the VB procedures work,but then ,when Application_ItemEvent() takes place,it is not recognized.

I tried to declare a company object in this last Sub Application_ItemEvent() giving it the value of the ,but this last one works properly ,instead the new object seems empty.

I tried everything,

Can you help me please??

Thenk you


Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2004 at 03:49 PM

    Hi Giammichele, your connection is bad!

    You use the connection Single Sign On.

    Ciao Giammichele, tu devi usare la connessione Single Sign On che ti allego sotto in VB.NET:

    Public sCookie As String

    SboGuiApi = New SAPbouiCOM.SboGuiApi

    StringaConnessione = Environment.GetCommandLineArgs.GetValue(1)


    applic = SboGuiApi.GetApplication()

    oCompany = New SAPbobsCOM.Company

    sCookie = oCompany.GetContextCookie

    sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)

    If oCompany.Connected = True Then


    End If

    If Not oCompany.SetSboLoginContext(sConnectionContext) = 0 Then

    SBO_Application.MessageBox("Impossibile stabilire una connessione")


    End If

    oCompany.UseTrusted = False

    If Not oCompany.Connect = 0 Then

    SBO_Application.MessageBox("Impossibile connettersi al database")


    End If

    Best Regards


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2004 at 11:25 AM

    Visual studio.NET

    XP professional

    SAP Business one 2004 A (6.70.165) DEMO

    this is my app code:

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim WithEvents a As SAPbouiCOM.Application

    Dim compagnia As New SAPbobsCOM.Company

    Dim bp As SAPbobsCOM.BusinessPartners

    Dim txtcardname As SAPbouiCOM.EditText

    Dim frmUnico As SAPbouiCOM.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim gui As New SAPbouiCOM.SboGuiApi


    a = gui.GetApplication

    compagnia.Password = a.Company.UserName

    compagnia.UserName = a.Company.UserName

    compagnia.Server = "rossini"

    compagnia.CompanyDB = "ROGA2"


    Dim path As String

    Dim xmlD As New MSXML2.DOMDocument

    path = System.Reflection.Assembly.GetExecutingAssembly.Location

    path = path.Substring(0, path.LastIndexOf("bin")) & "form2.srf"



    bp = compagnia.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    MsgBox(compagnia.Server) '------ (WORKS!!!!)----


    a.MessageBox(bp.CardName) '------ (WORKS!!!!)----

    MsgBox(bp.CardName) '------ (WORKS!!!!)----

    End Sub

    Private Sub a_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles a.ItemEvent

    Select Case pVal.FormType

    Case 134

    Select Case pVal.EventType

    Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD

    End Select

    Case 2000003000

    Select Case pVal.EventType

    Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD

    Dim d As New SAPbobsCOM.Company

    frmUnico = a.Forms.Item(pVal.FormUID)

    frmUnico.Title = "New form XML"

    txtcardname = frmUnico.Items.Item("txtCN").Specific

    Case SAPbouiCOM.BoEventTypes.et_CLICK

    Select Case pVal.ItemUID

    Case "cmdClic"

    If pVal.Before_Action = True Then

    a.MessageBox("called event on click chiamato") '------ (WORKS!!!!)----

    a.MessageBox(compagnia.Server) '------ (*****NOT WORKS******)----


    a.MessageBox(bp.CardName) '------ (*****NOT WORKS******)----

    txtcardname.Value = bp.CardName '------ (*****NOT WORKS******)----

    End If

    End Select

    End Select

    End Select

    End Sub

    End Class

    Could it be a limitation of SBO 2004 DEMO?

    I think I can't manage DI objects from UI.

    I'm wrong?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.