cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix Row Deletion Cannot Updated to Data Source

0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185682
Active Contributor
0 Kudos

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

0 Kudos

Hi DIEGO LOTHER

Thanks For Your Reply.

Still I am Facing the Same Problem.Matrix Row Only Deleted But the same record in Data Source is Not Deleted.

Kind Regards,

Chidambaram

former_member185682
Active Contributor
0 Kudos

Hi Chidambaram,

Please if possible share your code. How you bind your matrix, and how you are delete the row.

Kind Regards,

Diego Lother

0 Kudos

Hi DIEGO LOTHER

Here is the Code

Matrix Bind Code

Public Sub BindDataToForm()




        oColumns = oMatrix.Columns


        oColumn = oColumns.Item("Final1")
        oColumn.DataBind.SetBound(True, "@UDT", "UDF")
        oColumn = oColumns.Item("Check")
        oMatrix.Columns.Item("Check").ValOff = "N"
        oMatrix.Columns.Item("Check").ValOn = "Y"
        oMatrix.Columns.Item("Check").DataBind.SetBound(True, "@UDT", "UDF")


       
        oItem = oForm.Items.Add("AddRow", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
        oItem.Left = 360


        oItem.Top = 160


        obutton = oItem.Specific


        obutton.Caption = "Add Row"
        oItem = oForm.Items.Add("DeleteRow", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
        oItem.Left = 220


        oItem.Top = 160


        obutton = oItem.Specific


        obutton.Caption = "DeleteRow"


'// DELETE ROW


Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
        Dim ds As SAPbouiCOM.DBDataSource


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


        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
            Dim oExeMatDtl As SAPbouiCOM.DBDataSource
            irow = oMatrix.GetNextSelectedRow(0, SAPbouiCOM.BoOrderType.ot_SelectionOrder)
            
            oExeMatDtl = oForm.DataSources.DBDataSources.Item("@UDT")
            oExeMatDtl.Clear()
            Try
                oMatrix = oForm.Items.Item("Matrix1").Specific
                oMatrix.DeleteRow(irow)
                oMatrix.IsRowSelected(irow)
                oForm.DataSources.DBDataSources.Item("@UDT").RemoveRecord(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

former_member185682
Active Contributor
0 Kudos

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