Skip to Content

Matrix Row Deletion Cannot Updated to Data Source

Hi All,

I am Using UDT as DB Data source.I created a User Form With Matrix,Add Row Button and Delete Row Button.

1.Add Row Button is Working Correctly

2.When I Clicked Delete Row Button,......... Row in Matrix is Deleted But Not Deleted in Data Source...odbDataSource.RemoveRecord(0) this line is not working

Please Help Me to Solve this Issue

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 27, 2017 at 12:01 PM

    Hi Chidambaram,

    You can perform this action with this:

    Add row:

    oMtx.AddRow(1, your index);
    oMtx.FlushToDataSource();
    

    Delete Row:

    oMtx.DeleteRow(your index);
    oMtx.FlushToDataSource();
    

    Every time when you call FlushToDataSource method, the SDK will update the datasource with the values of your matrix.

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Chidambaran,

      Try with this changes:

      For Add Row:

      If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "AddRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = True)) Then
      	Dim count As Integer = oMatrix.RowCount
      	oMatrix.AddRow(1, count)
      	oMatrix.FlushToDataSource()
      	oMatrix.Columns.Item(1).Cells.Item(oMatrix.RowCount).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
      End If

      For Delete Row:

      If ((pVal.FormUID = "fORMuid") And (pVal.ItemUID = "DeleteRow") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = False)) Then
      
      
      	Dim irow As Integer
      	irow = oMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)
      	
      	Try
      		oMatrix = oForm.Items.Item("Matrix1").Specific
      		oMatrix.DeleteRow(irow)
      		oMatrix.FlushToDataSource()
      	Catch ex As Exception
      		MsgBox(ex.Message)
      	End Try
         
      	If oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
      		oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE
      	End If
      	
      End If

      Only remember that delete row from a dbdatasource does not reflect directly on database, only on the object on the form.

      If you want delete or add a row for database you need use DI API together with UI API.

      Hope it helps.

      Kind Regards,

      Diego Lother