Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Right-Click Custom Menu

Good Day

Experts:

Well, I have revisited my old friend the Right-Click custom menu set-up. After today I am at "witts" end andnot sure what to do. Here is what I have going.

1)Form with multiple Tabs

2)2 of the Tabs need seperate right-click menus and the rest need nothing

I will attach the code at the end. The toggling back and forth between Tabs produces the correct corresponding menu. All is great. However, as soon as I execute one of the menu selections, which happens to run correctly, the right-click

menus stop toggling correctly between the Tabs. So, I put a breakpoint in the right-click event routine and it never gets in there.

So, here is what I have in the right-click event routine. Hopefully I am missing something that you all can see.

Thanks Ed

Public Sub RightClickEvent(ByRef eventInfo As SAPbouiCOM.ContextMenuInfo, ByRef BubbleEvent As Boolean)

Try

If (eventInfo.BeforeAction = True) Then

Select Case eventInfo.ItemUID

<b>Case "mtxOper"</b>

If g_B1Connection.Application.Menus.Exists("Update Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Update Material Row")

End If

If g_B1Connection.Application.Menus.Exists("Add Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Add Material Row")

End If

If g_B1Connection.Application.Menus.Exists("Delete Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Delete Material Row")

End If

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = g_B1Connection.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Update Operation Row"

oCreationPackage.String = "Update Operation Row"

oCreationPackage.Position = 1

WOForm.Menu.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Add Operation Row"

oCreationPackage.String = "Add Operation Row"

oCreationPackage.Position = 2

WOForm.Menu.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Delete Operation Row"

oCreationPackage.String = "Delete Operation Row"

oCreationPackage.Position = 3

WOForm.Menu.AddEx(oCreationPackage)

<b> Case "mtxMatl"</b>

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = g_B1Connection.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Update Material Row"

oCreationPackage.String = "Update Material Row"

oCreationPackage.Position = 1

WOForm.Menu.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Add Material Row"

oCreationPackage.String = "Add Material Row"

oCreationPackage.Position = 2

WOForm.Menu.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Delete Material Row"

oCreationPackage.String = "Delete Material Row"

oCreationPackage.Position = 3

WOForm.Menu.AddEx(oCreationPackage)

<b>Case Else</b>

If g_B1Connection.Application.Menus.Exists("Update Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Update Material Row")

End If

If g_B1Connection.Application.Menus.Exists("Add Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Add Material Row")

End If

If g_B1Connection.Application.Menus.Exists("Delete Material Row") Then

g_B1Connection.Application.Menus.RemoveEx("Delete Material Row")

End If

If g_B1Connection.Application.Menus.Exists("Update Operation Row") Then

g_B1Connection.Application.Menus.RemoveEx("Update Operation Row")

End If

If g_B1Connection.Application.Menus.Exists("Add Operation Row") Then

g_B1Connection.Application.Menus.RemoveEx("Add Operation Row")

End If

If g_B1Connection.Application.Menus.Exists("Delete Operation Row") Then

g_B1Connection.Application.Menus.RemoveEx("Delete Operation Row")

End If

End Select

Else

Select Case eventInfo.ItemUID

Case "mtxOper"

g_B1Connection.Application.Menus.RemoveEx("Update Operation Row")

g_B1Connection.Application.Menus.RemoveEx("Add Operation Row")

g_B1Connection.Application.Menus.RemoveEx("Delete Operation Row")

Case "mtxMatl"

g_B1Connection.Application.Menus.RemoveEx("Update Material Row")

g_B1Connection.Application.Menus.RemoveEx("Add Material Row")

g_B1Connection.Application.Menus.RemoveEx("Delete Material Row")

End Select

End If

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

Former Member
Not what you were looking for? View more on this topic or Ask a question