cancel
Showing results for 
Search instead for 
Did you mean: 

Remove record on the right click event

Former Member
0 Kudos

I have created a new form through screen painter for adding user defined fields.I want to delete record by right clicking on the form and selecting Remove.This functionality can be seen in Item Master.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If ur dealing with a UDO this can be very easily achieved..

After the form load execute this code so that the menu will be enabled.

objForm.EnableMenu("1283", True)

this will enable the menu.

If ur form is not an UDO then in the menu CLICK u have u write the code to delete the record.

Hope it helps,

Vasu Natari.

Former Member
0 Kudos

Vasu,

I have enabled the menu as,

objForm.EnableMenu("1283", True)

I have fired the Delete function as,


Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
        If pVal.MenuUID = "1283" And pVal.BeforeAction = True And pVal.InnerEvent = False Then
            Delete()
        End If
    End Sub

But the event is getting fired multiple times.I want to perform delete operation only once.It works prpoerly when the first is loaded for the first time.Afterwards,the event is fired multiple times.

Former Member
0 Kudos

Hi,

Please make the following change and check..

Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent
        If pVal.MenuUID = "1283" And pVal.BeforeAction = True And pVal.InnerEvent = False Then
            Delete()
            BubbleEvent = False
        End If
    End Sub

Hope it solves the problem,

Vasu Natari.

Former Member
0 Kudos

Hi Dilip,

I hope this thread will help you.

Regards

Vishnu

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try this Code:

Before that Enable the menu as

oForm.EnableMenu("1293",True)

Menu Event...

If (pVal.MenuUID = "1293") And (pVal.BeforeAction = False) Then

Try

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Dim omat As SAPbouiCOM.Matrix

Dim GCols As SAPbouiCOM.Columns

Dim i As Integer

oitem = OForm.Items.Item("Ur Matrix")

omat = oitem.Specific

GCols = omat.Columns

omat = OForm.Items.Item("urmatrix").Specific

For i = 1 To omat.RowCount

If omat.IsRowSelected(i) = True Then

omat.DeleteRow(i)

Exit For

End If

Next

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

Regards

Mohana

Former Member
0 Kudos

Hi...

use this code and change ur matrix id...

Private Sub SBO_Application_RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean) Handles SBO_Application.RightClickEvent

If eventInfo.FormUID = "Ur Form ID" Then

If (eventInfo.BeforeAction = True) Then

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Dim omat As SAPbouiCOM.Matrix

Dim GCols As SAPbouiCOM.Columns

oitem = OForm.Items.Item("Ur Matrix")

omat = oitem.Specific

GCols = omat.Columns

Try

selItem = eventInfo.ItemUID

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "OnlyOnRC"

oCreationPackage.String = "Delete Row"

oCreationPackage.Enabled = True

oMenuItem = SBO_Application.Menus.Item("1280") 'Data'

oMenus = oMenuItem.SubMenus

oMenus.AddEx(oCreationPackage)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

Else

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Try

SBO_Application.Menus.RemoveEx("OnlyOnRC")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End If

End If

End Sub

Menu Event...

If (pVal.MenuUID = "OnlyOnRC") And (pVal.BeforeAction = False) Then

Try

Dim oMenuItem As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Dim omat As SAPbouiCOM.Matrix

Dim GCols As SAPbouiCOM.Columns

Dim i As Integer

oitem = OForm.Items.Item("Ur Matrix")

omat = oitem.Specific

GCols = omat.Columns

omat = OForm.Items.Item(selItem).Specific

For i = 1 To omat.RowCount

If omat.IsRowSelected(i) = True Then

omat.DeleteRow(i)

Exit For

End If

Next

Catch ex As Exception

SBO_Application.MessageBox(ex.Message)

End Try

End If

It will work..

Regards..

Billa 2007