cancel
Showing results for 
Search instead for 
Did you mean: 

Delete row event

Former Member
0 Kudos

How do we know if a user deleted a line by the right click on the line and pressing Delete row ?

Or any way to know that a user is deleting a line so we can take action if so ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

menu event with id 1293 is generated

Former Member
0 Kudos

menu event with id 1293 is generated

This would be a good idea so if I go in MenuEvent and check if 1293 is generated. How will I know which line was deleted since pVal is a MenuEvent and not an ItemEvent

Former Member
0 Kudos

Im doing it as

If pVal.MenuUID = "1293" And pVal.BeforeAction = False Then
            Dim oform As SAPbouiCOM.Form
            oform = SBO_Application.Forms.ActiveForm
            If oform.UniqueID = "xform" Then
                Dim omatrix As SAPbouiCOM.Matrix
                omatrix = oform.Items.Item("Matrix1").Specific
                Dim q As Integer = 1
                For q = 1 To omatrix.RowCount
                    If omatrix.IsRowSelected(q) Then
                        omatrix.DeleteRow(q) -- here in q is selected row
                    End If
                Next
            End If
        End If

Former Member
0 Kudos

Thank you it works fine.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

use form load event,msg box form type='0' and if item=1(yes) else item=2(No).

try this one.

Regards,

Siva

Former Member
0 Kudos

This would be ok when I know which line the user wants to delete and the code I showed is prety complete but the problem is that when the user right click any line, even before the contextual menu appears to click DELETE ROW, the line is unselected by SAP which makes us unable to know which line the user want to delete.

The popup works prety good but is useless if once there we don't know which line was to be deleted.

Any good idea on the subject ?

Former Member
0 Kudos

Hi,

use this one in form load

objMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Single

Now you can select single row that row u can delete.

Regards,

Siva

Former Member
0 Kudos

Can you use the Click and Rightclick events to monitor what line the user is clicking, store it in a variable and then use it when the delete row menuuid is raised?

Former Member
0 Kudos

Can you use the Click and Rightclick events to monitor what line the user is clicking, store it in a variable and then use it when the delete row menuuid is raised?

That's what I did and it works. thank you for the idea.

However I would point that this is a workaround something that should be easier for us to work with. I don't know where to post suggestion to SAP to improve the product since I develop for SAP for about 5 years now I find things that never changed and would make developer happy by making slight changes to the way we work with the System matrix

Former Member
0 Kudos

I tried the last suggestions and when I right click the line to delete it. the IsRowSelected returns false as it looks like unselected after right clicking it. How do I get the line the user wanted to delete so I can pop a message asking if he's sure he wants to delete the line

Former Member
0 Kudos

Here's the code :

if (pVal.MenuUID == "1293" && pVal.BeforeAction)
{
    SAPbouiCOM.Form oForm = SBO_Application.Forms.ActiveForm;

    if (oForm.Type == SAPFramework.Enums.FORMS_TYPE.B1_SALESORDER)
    {
        SAPbouiCOM.Matrix oMatrix = oForm.Items.Item(SAPFramework.Enums.MATRIX_TYPE.B1_SALESORDER).Specific as SAPbouiCOM.Matrix;

        for (int iRowToSearch = 1; iRowToSearch < oMatrix.RowCount; iRowToSearch++)
        {
            // This doesn't seem to work as none of the lines in the matrix are selected even thought I selected it before deleting it
            // The way I do it is right clicking the line and using the context menu to delete but when the context menu appears the line is unselected
            if (oMatrix.IsRowSelected(iRowToSearch))
            {
                if ("CP, SS, TR".IndexOf(((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("ItemCode", iRowToSearch)).Value, StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    if (SBO_Application.MessageBox("Êtes-vous certain de vouloir effecer ce kit ?", 2, "Oui", "Non", "") == 1)
                    {
                        //-------------------------------------------------------------------------------------------------------------
                        // Keep the KitSeq of the parent and start searchning it in the matrix to delete all line that have this KitSeq
                        //-------------------------------------------------------------------------------------------------------------
                        string KitSeq = ((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("U_KitSeq", iRowToSearch)).Value;

                        for (int iRowToDelete = 1; iRowToDelete < oMatrix.RowCount; iRowToDelete++)
                        {
                            if (((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("U_KitSeq", iRowToDelete)).Value == KitSeq)
                            {
                                oMatrix.DeleteRow(iRowToDelete);
                                iRowToDelete--;
                            }
                        }
                    }
                }

                break;
            }
        }
    }
}

Former Member
0 Kudos

Hi Marc,

Try This.......


'Before deleting a row it pop up a message box for confirmation 
Try
                Dim omatrix As SAPbouiCOM.Matrix
                oform = sbo_application.Forms.Item(FormUID)
                omatrix = oform.Items.Item("mat_emp").Specific
                If omatrix.RowCount > 0 Then
                    'sbo_application.MessageBox(omatrix.RowCount)
                    'sbo_application.MessageBox(omatrix.VisualRowCount)
                    For i As Integer = 1 To omatrix.RowCount
                        If omatrix.IsRowSelected(i) = True Then
                            'sbo_application.MessageBox("Row" & i & "is Selected")
                            Dim odb As SAPbouiCOM.DBDataSource
                            Dim result As Integer
                            result = sbo_application.MessageBox("Do You Want to Delete This Row", 1, "OK", "Cancel")
                            If result = 1 Then
                               omatrix.DeleteRow(i)
                            End If
                            'omatrix.DeleteRow(i)
                                                       'End If
                        End If
                    Next
                End If
            Catch ex As Exception
                sbo_application.MessageBox(ex.Message)
            End Try

Thanks

Shafi

Former Member
0 Kudos

Hi,

If row is delete from such document you can come to know by Change Log , but It hard to find which row was deleted .

Thanks

Kevin