cancel
Showing results for 
Search instead for 
Did you mean: 

Option under New Module

Former Member
0 Kudos

Hi

  I have created 1 UDT with 3 fields . It appears under Tools->User Defined Windows when i click Form Opens . I want this form to open under a Sub Menu i created .

    Private Sub AddMenuItems()

        Dim oMenus As SAPbouiCOM.Menus

        Dim oMenuItem As SAPbouiCOM.MenuItem

        oMenus = SBO_Application.Menus

        Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

        oMenuItem = SBO_Application.Menus.Item("43520")

        Dim sPath As String

        sPath = Application.StartupPath

        sPath = sPath.Remove(sPath.Length - 3, 3)

        oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP

        oCreationPackage.UniqueID = "MyMenu"

        oCreationPackage.String = "New Module"

        oCreationPackage.Enabled = True

        oCreationPackage.Image = sPath & "UI.bmp"

        oCreationPackage.Position = 15

        oMenus = oMenuItem.SubMenus

        Try ' If the manu already exists this code will fail

            oMenus.AddEx(oCreationPackage)

            '// Get the menu collection of the newly added pop-up item

            oMenuItem = SBO_Application.Menus.Item("MyMenu")

            oMenus = oMenuItem.SubMenus

End Sub

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

edy_simon
Active Contributor
0 Kudos

Hi Sunny,

Catch the event when user click you menu,

then execute this :

SBO_Application.ActivateMenuItem("DefaultFormUID")

Where DefaultFormUID is the MenuUID of your from under Tools->User Defined Windows.

Note that this DefaultFormUID is dynamic. when you create another UserDefinedWindows, this menuUID will change.

You need to look up for the correct menu UID.

Check out this Post

Regards
Edy

Former Member
0 Kudos

Hi Edy

  I have written like this . it's not working . If i write only this SBO_Application.ActivateMenuItem("51201") then it works.

Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent

        If pVal.BeforeAction = False Then

            Select Case pVal.MenuUID

                Case "MySubMenu"

                    Dim oMenu As SAPbouiCOM.MenuItem

                    Dim i As Integer

                    Dim menuuid As Long

                    oMenu = SBO_Application.Menus.Item("51201")

                    For i = 0 To oMenu.SubMenus.Count - 1

                        If oMenu.SubMenus.Item(i).String = "TEMP" Then

                            menuuid = oMenu.SubMenus.Item(i).UID

                            Exit For

                        End If

                    Next

                    SBO_Application.ActivateMenuItem(MenuUID)

                    'SBO_Application.ActivateMenuItem("51201")

                End Select

        End If

    End Sub

edy_simon
Active Contributor
0 Kudos

Hi Sunny,

Change this line

oMenu = SBO_Application.Menus.Item("51201")

to :

oMenu = SBO_Application.Menus.Item("51200")

Regards

Edy


Former Member
0 Kudos

Hi Edy

   When i write like this

If oMenu.SubMenus.Item(i).String = "TEMP - TEMP" Then

then it is working . It means i have to write table name & description

Thanks

Answers (0)