cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Row In Matrix

former_member196647
Contributor
0 Kudos

Hello All,

I have a UDO and a form for it. The UDO has a child table, which is binded to a matrix in the form. Everything works well except Delete Row in the matrix.

If I don't do anything when Delete Row menu is clicked, the row is deleted. But as soon as Update button is clicked, a new empty row gets added to the matrix and the underlying table.

The same happens even if I catch the delete row event, do the delete myself and then set the bubbleevent to false.

Is this the default behaviour. What is the workaround to avoid this addition of new empty row.

Following is the code I am using for deleting the row. I've used various combinations of this code to the same affect.



        Dim oMatrix As SAPbouiCOM.Matrix
        Dim RowIndex As Integer

        Try
            If oForm.Mode <> SAPbouiCOM.BoFormMode.fm_FIND_MODE Then
                oMatrix = oForm.Items.Item("AC_MX01").Specific
                RowIndex = oMatrix.GetNextSelectedRow

                If RowIndex <= 0 Then
                    Exit Sub
                End If

                oForm.DataSources.DBDataSources.Item("@AC_SMP1").RemoveRecord(RowIndex - 1)
                oMatrix.DeleteRow(RowIndex)
                'oMatrix.FlushToDataSource()

                'oMatrix.LoadFromDataSource()
            Else
                Exit Sub
            End If

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member689126
Active Contributor
0 Kudos

Hi Rahul

Try this code


        Dim oMatrix As SAPbouiCOM.Matrix
        Dim RowIndex As Integer
        
        oMatrix = oForm.Items.Item("AC_MX01").Specific
        For RowIndex = 1 To oMatrix.RowCount
             If oMatrix.IsRowSelected(RowIndex) = True Then
                 oMatrix.DeleteRow(RowIndex)
                 oMatrix.FlushToDataSource()
                 If form.Mode = 1 Then form.Mode = BoFormMode.fm_UPDATE_MODE
                 Exit For
             End If
       Next

Hope this helps....

Kind Regards

Arun TB