Skip to Content
avatar image
Former Member

Matrix with combo box include additional row

I have a matrix in my form with Combo box and loaded the matrix from data source but there is an additional row also included which is not available in the data source.

oForm = oApplication.SBO_Application.Forms.Item(strUID)
oForm.Items.Item("9").Specific.Value = Code
oForm.Items.Item("4").Specific.Value = Name

strSQL = "select Code from [@BZ_OTIR] where Code='" & Code & "'"
oRecordSet = oApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecordSet.DoQuery(strSQL)

If oRecordSet.EoF Then
oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE
Else
oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
End If

Dim oMatrix As SAPbouiCOM.Matrix = oForm.Items.Item("5").Specific
Dim oDBDataSourceLines As SAPbouiCOM.DBDataSource = oForm.DataSources.DBDataSources.Item("@BZ_TIR1")

Dim recordCount As Integer = oRecordSet.RecordCount
oMatrix.Clear()
oDBDataSourceLines.Clear()

Dim intRow As Integer = 0
strSQL = "exec [LoadTier] '" & Code & "'"
oRecordSet.DoQuery(strSQL)
oMatrix.Columns.Item("V_3").Editable = True
If Not oRecordSet.EoF Then
While Not oRecordSet.EoF
oMatrix.AddRow(1, oMatrix.RowCount)
oMatrix.FlushToDataSource()
oDBDataSourceLines.SetValue("LineId", intRow, (intRow + 1).ToString())
oDBDataSourceLines.SetValue("U_Brand", intRow, oRecordSet.Fields.Item("Brand").Value.ToString())
oDBDataSourceLines.SetValue("U_Category", intRow, oRecordSet.Fields.Item("Category").Value.ToString())
oDBDataSourceLines.SetValue("U_Segment", intRow, oRecordSet.Fields.Item("Segment").Value.ToString())
oDBDataSourceLines.SetValue("U_Tier", intRow, oRecordSet.Fields.Item("Tier").Value.ToString())

intRow = intRow + 1
oRecordSet.MoveNext()
End While
End If

oMatrix.LoadFromDataSource()
oMatrix.FlushToDataSource()

capture.jpg (15.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 28, 2017 at 03:25 PM

    Hi,

    Not sure why have you used oMatrix.FlushToDataSource() two times? Below sample code should work for you:

    SAPbouiCOM.DBDataSource dbData = default(SAPbouiCOM.DBDataSource);
    dbData = (SAPbouiCOM.DBDataSource)m_SBO_Form.DataSources.DBDataSources.Item("@LINETABLE");
    if (oMatrix.VisualRowCount == 0)
    {
        dbData.Clear();
        oMatrix.AddRow(1, oMatrix.VisualRowCount);
        oMatrix.FlushToDataSource();
        this.m_SBO_Form.DataSources.DBDataSources.Item("@LINETABLE").SetValue("U_Code", oMatrix.VisualRowCount - 1, "");
        oMatrix.LoadFromDataSource();
    }
    

    Hope it helps!

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded