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

Trying to Bind Matrix to DBDatasource


I cannot seem to get my matrix bound to a system datasource (POR1)

The Error I get is "Data Source - Not A User Datasource"

This occurs when trying to bind the first column.

( colItem.DataBind.SetBound(True, "POR1", "ItemCode" )

I am trying to do this in a new tab in the purchase order form (142)

odbs is a variable with class scope.

Please help :

        odbs = oform.DataSources.DBDataSources.Add("POR1")

        oNewItem = oform.Items.Add("Lmat", SAPbouiCOM.BoFormItemTypes.it_MATRIX)
        oItem = oform.Items.Item("38")
        oNewItem.Left = oitem.Left
        oNewItem.Width = oItem.Width
        oNewItem.Top = oitem.Top
        oNewItem.Height = oitem.Height
        oNewItem.AffectsFormMode = False

        oNewItem.FromPane = 15
        oNewItem.ToPane = 15
        omat = oNewItem.Specific
        Dim colItem As SAPbouiCOM.Column
        Dim colItemD As SAPbouiCOM.Column
        Dim colQty As SAPbouiCOM.Column
        Dim colQtyO As SAPbouiCOM.Column
        Dim colSO As SAPbouiCOM.Column
        Dim l As SAPbouiCOM.LinkedButton
        Dim l2 As SAPbouiCOM.LinkedButton

        colItem = omat.Columns.Add("colItem", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON)
        colItem.Width = "125"
        colItem.TitleObject.Caption = "Item"
        colItem.DataBind.SetBound(True, "POR1", "ItemCode")
        colItem.Visible = True
        l = colItem.ExtendedObject
        l.LinkedObject = SAPbouiCOM.BoLinkedObject.lf_Items

        colItemD = omat.Columns.Add("colItemTxt", SAPbouiCOM.BoFormItemTypes.it_EDIT)
        colItemD.Width = "225"
        colItemD.TitleObject.Caption = "Item Name"
        colItemD.DataBind.SetBound(True, "POR1", "Dscription")
        colItemD.Visible = True

        colQty = omat.Columns.Add("colQty", SAPbouiCOM.BoFormItemTypes.it_EDIT)
        colQty.Width = "75"
        colQty.TitleObject.Caption = "Qty"
        colQty.DataBind.SetBound(True, "POR1", "Quantity")
        colQty.Visible = True

        colQtyO = omat.Columns.Add("colQtyO", SAPbouiCOM.BoFormItemTypes.it_EDIT)
        colQtyO.Width = "75"
        colQtyO.TitleObject.Caption = "Qty"
        colQtyO.DataBind.SetBound(True, "POR1", "OpenQty")
        colQtyO.Visible = True

        colSO = omat.Columns.Add("colSO", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON)
        colSO.Width = "125"
        colSO.TitleObject.Caption = "Sales Order"
        colSO.DataBind.SetBound(True, "POR1", "U_SONumber")
        colSO.Visible = True
        l2 = colSO.ExtendedObject
        l2.LinkedObject = SAPbouiCOM.BoLinkedObject.lf_Order

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Dec 18, 2008 at 07:03 AM

    Hello nick,

    Unfortunately, we can't bind DBDatasource to system table fields. See restrictions of DBDataSource below from SDK Help.

    The following restrictions apply to original SAP Business One DBDataSource objects:

    You cannot perform a query on the data source or change its offset.

    You can only attach items to user-defined fields in the data source.

    If the scenario is just displaying the data without modification, you may try Grid and DataTable instead of Matrix and DataTable.

    oGrid.DataTable.ExecuteQuery(""Select 0, CardName, CardType, GroupNum from OCRD")

    You can refer to SDK Sample or Help for more info.

    Regards, Yatsea

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 10:00 PM

    I know I can with the Grid however I want a linkbutton to the Sales Order - I cannot seem to work out how this is done with the Grid

    Add a comment
    10|10000 characters needed characters exceeded

    • Nick,

      Yes, you can add link button in grid column. There are 4 type of GridColumn, CheckBoxColumn, ComboBoxColumn, EditTextColumn, PictureColumn objects. And you can set the linkobjecttype for EditTextColumn

      Please refer to BoGridColumnType for more info.

      sample code:

      oItem = oItems.Add("My_Grid", SAPbouiCOM.BoFormItemTypes.it_GRID)
                  oItem.Top = 30
                  oItem.Left = 10
                  oItem.Width = 200
                  oItem.Height = 100
                  Dim oGrid As SAPbouiCOM.Grid = oItem.Specific
                  Dim oDataTable = oForm.DataSources.DataTables.Add("POLines")
                  oGrid.DataTable = oDataTable
                  oDataTable.ExecuteQuery("SELECT ItemCode AS 'Item Code', Dscription AS 'Item Name', Quantity FROM POR1 WHERE DocEntry = 1")
                  Dim colItemCode As SAPbouiCOM.GridColumn = oGrid.Columns.Item(0)
                  colItemCode.Type = SAPbouiCOM.BoGridColumnType.gct_EditText            
                  Dim editColItemCode As SAPbouiCOM.EditTextColumn = CType(colItemCode, SAPbouiCOM.EditTextColumn)
                  editColItemCode.LinkedObjectType = 4

      Regards, Yatsea

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 04:15 AM

    I managed to bind this by using :

    Databound.Bind rather than Databound.Setbound

    However now I get gobbeldygook in the number columns (Qty and Open Qty) and the Sales order link tries to use the DocEntry rather than the DocNo to open the SO form ....

    Any help here ?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 04:30 AM

    I should explain further - I have gone back to a datatable and a Query to load this matrix using databind.bind - it works for the first time but is causing the problems stated in the last post.

    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.