Skip to Content
author's profile photo
Former Member

Use SAPbouiCOM.ActiveX

I use the ActiveX functionality in BusinessOne UI that supports ATL technology : i use the control MSCOMCTL.OCX (Release in Visual Basic.Net project.

When i try to incorporated control from MSCOMCTL.OCX in my code like this :

1:Dim ActiveXTreeObject As SAPbouiCOM.ActiveX

2:Dim TreeViewControl As MSComctlLib.TreeView

3:ActiveXTreeObject = oItem.Specific

4:ActiveXTreeObject.ClassID = "MSComctlLib.TreeCtrl.2"

5:TreeViewControl = ActiveXTreeObject.Object

I have an error message in VisualBasic (A not managed exception of the type 'System.Runtime.InteropServices.COMException' occurred in MainProg.exe. Informations additional: Exception of HRESULT : 0xFFFFFFFF.

) and the applicatrion close BusinesOne.

Have you an idea ?


Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Posted on Mar 09, 2005 at 08:08 AM

    Hi francis,

    I could instantiate the TreeViewControl (same version of the library) without any issue / exception (steps 1-5 + the code you did not post...).

    I am using PL 09. Which PL do you use?

    Could you post some more code?



    PS: When I try the code below everything works fine. Maybe you should unregister/register the library again?

    I use XP (SP1) + .NET 1.1.4322 + Visual Studio 2003

    The code I used successfully:

    Dim oForm As SAPbouiCOM.Form
    Dim oItem As SAPbouiCOM.Item
    Dim oItemX As SAPbouiCOM.Item
    Dim oActX As SAPbouiCOM.ActiveX
    Dim TreeViewControl As MSComctlLib.TreeView
    oForm = SBO_Application.Forms.Item...
      oForm.Width = 600
      oForm.Height = 500
      oItemX = oForm.Items.Add("TC", it_ACTIVE_X)
      oItemX.Width = oForm.Width - 10
      oItemX.Height = oForm.Height - 20
      oActX = oItemX.Specific
      oActX.ClassID = "MSComctlLib.TreeCtrl.2"
      TreeViewControl = oActX.Object
      'Loading date to Tree Nodes
      Dim BPNode As MSComctlLib.Node
      Dim ContactNode As MSComctlLib.Node
      Dim oRecordSet As SAPbobsCOM.Recordset
      Dim oBPs As SAPbobsCOM.BusinessPartners
      Dim iContact As Integer
      Dim sKey As String
      ' Connect to DI API...
      If SetConnection() <> 0 Then Exit Sub
      ' Reference all the Business Partners
      oRecordSet = oCompany.GetBusinessObject(BoRecordset)
      'Please note that there was a bug around "Select *" 
      'or "Select Fld1,<BLANK!>Fld2" in earlier versions of 
      'DI API in conjunction with the data browser...
      oRecordSet.DoQuery("SELECT CardCode FROM OCRD")
      oBPs = oCompany.GetBusinessObject(oBusinessPartners)
      oBPs.Browser.Recordset = oRecordSet
      ' Iterate all the BPs
      While oBPs.Browser.EoF = False
        sKey = "B" & oBPs.CardCode
        BPNode = TreeViewControl.Nodes.Add(, , sKey, oBPs.CardName)
        For iContact = 0 To oBPs.ContactEmployees.Count() - 1
          If oBPs.ContactEmployees.Name <> "" Then
            ContactNode = TreeViewControl.Nodes.Add(, , _
                          "C" & oBPs.CardCode & iContact.ToString, _
            ContactNode.Parent = BPNode
          End If
        Next iContact
      End While
    Catch ex As Exception
    End Try

    Add comment
    10|10000 characters needed characters exceeded