cancel
Showing results for 
Search instead for 
Did you mean: 

Menu Item

Former Member
0 Kudos

Hi to All

I create a folder under production menu and in that folder i add the 7 sub menu items.so its not working properly.But when i delete the 7th sub menu item then it work properly.What is the problem?

Is there any condition One menu having not more than 6 Menu item?

With Regards,

M.Thippa Reddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Thippa Reddy,

I think there are no restrictions about the number of submenu.

Can you post your code ?

Regards

Michael

Former Member
0 Kudos

Hi Michel

Thanks for responding .Now my code is posting

Public Class Class1

Private WithEvents SBO_Application As SAPbouiCOM.Application

Private oCompany As SAPbobsCOM.Company

Private oForm As SAPbouiCOM.Form

Public filename As String

Private Sub SetApplication()

Dim SboGuiApi As SAPbouiCOM.SboGuiApi

Dim sConnectionString As String

SboGuiApi = New SAPbouiCOM.SboGuiApi

sConnectionString = Environment.GetCommandLineArgs.GetValue(1)

' SboGuiApi.AddonIdentifier = "5645523035446576656C6F706D656E743A5A30373230323930373738EC3687D2B9A92E329D04C54AF12A09636A334302"

SboGuiApi.Connect(sConnectionString)

SBO_Application = SboGuiApi.GetApplication()

End Sub

Private Function SetConnectionContext() As Integer

Dim sCookie As String

Dim sConnectionContext As String

Try

oCompany = New SAPbobsCOM.Company

sCookie = oCompany.GetContextCookie

sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)

If oCompany.Connected = True Then

oCompany.Disconnect()

End If

'// Set the connection context information to the DI API.

SetConnectionContext = oCompany.SetSboLoginContext(sConnectionContext)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Function

Private Function ConnectToCompany() As Integer

'// Establish the connection to the company database.

ConnectToCompany = oCompany.Connect

End Function

Public Sub New()

MyBase.New()

SetApplication()

If Not SetConnectionContext() = 0 Then

SBO_Application.MessageBox("Failed setting a connection to DI API")

End

End If

If Not ConnectToCompany() = 0 Then

SBO_Application.MessageBox("Failed connecting to the company's Data Base")

End

End If

SBO_Application.MessageBox("DI Connected To: " & oCompany.CompanyName & "Add-on is loaded")

AddMenuItems() ' Menu for Jobwork Issues

' AddMenuItems1() ' Menu for User Reports

' AddMenuItems1()

End Sub

Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent

Select Case EventType

Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown

SBO_Application.MessageBox("A Shut Down Event has been caught" & _

Environment.NewLine() & "Terminating 'Add Menu Item' Add On...")

'// terminating the Add On

System.Windows.Forms.Application.Exit()

End Select

End Sub

Private Sub AddMenuItems() ' Jobwork Receipts Menu adding

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

oMenuItem = SBO_Application.Menus.Item("4352") ' production menu id

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP

oCreationPackage.UniqueID = "MyMenu"

oCreationPackage.String = "Manifacturing"

oCreationPackage.Enabled = True

oCreationPackage.Position = 2

oMenus = oMenuItem.SubMenus

Try ' If the manu already exists this code will fail

oMenus.AddEx(oCreationPackage)

submenuitem1()

submenuitem2()

submenuitem3()

submenuitem4()

submenuitem5()

submenuitem6()

submenuitem7()

submenuitem8()

submenuitem9()

'2nd Menuitem

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

'oMenus = oMenuItem.SubMenus

''// Create s sub menu

'oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

'oCreationPackage.UniqueID = "SBOFormEditor_11"

'oCreationPackage.String = "Dispensing"

'oMenus.AddEx(oCreationPackage)

'oCreationPackage.Position = 2

Catch er As Exception ' Menu already exists

SBO_Application.MessageBox("Menu Already Exists")

End Try

End Sub

Public Sub submenuitem1()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Dispensing"

oCreationPackage.String = "Dispensing"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem2()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Sizing"

oCreationPackage.String = "Sizing"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem3()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Powderblending"

oCreationPackage.String = "Powderblending"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem4()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Granulation"

oCreationPackage.String = "Granulation"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem5()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Drying"

oCreationPackage.String = "Drying"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem6()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Tabletcompression"

oCreationPackage.String = "Tabletcompression"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem7()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Cleaning"

oCreationPackage.String = "Cleaning"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem8()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Inprocessqualitycontrol"

oCreationPackage.String = "Inprocessqualitycontrol"

oMenus.AddEx(oCreationPackage)

End Sub

Public Sub submenuitem9()

Dim oMenus As SAPbouiCOM.Menus ' The menus collection

Dim oMenuItem As SAPbouiCOM.MenuItem ' The new menu item

oMenus = SBO_Application.Menus

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

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

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

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

oMenus = oMenuItem.SubMenus

'// Create s sub menu

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "FinalProducttest"

oCreationPackage.String = "FinalProducttest"

oMenus.AddEx(oCreationPackage)

End Sub

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

'Dispensive

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

filename = "dispensing.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Dispensing")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'Sizing

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

filename = "sizing.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Sizing")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'PowederBlending

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

filename = "poweblending.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Powderblending")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'Granulation

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

filename = "granulation.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Granulation")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'DryingDrying

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

filename = "Drying.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Drying")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'TabletCompression

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

filename = "Tabletcompression.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Tabletcompression")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'Cleaning

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

filename = "Cleaning.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Cleaning")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'Inprocess Quality Control

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

filename = "Inprocess.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("Inprocessqualitycontrol")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

'Final Product Testing

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

filename = "Finalproducttest.srf"

SBO_Application.MessageBox("My sub menu item was clicked")

Try

oForm = SBO_Application.Forms.Item("FinalProducttest")

oForm.Select()

Catch ex As Exception

DrawForm(filename)

oForm.SupportedModes = -1

End Try

End If

End Sub

Private Sub DrawForm(ByRef filename As String) ' Drawing form

Try

LoadFromXML(filename)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

Private Sub LoadFromXML(ByRef filename As String)

Dim oXmlDoc As Xml.XmlDocument

oXmlDoc = New Xml.XmlDocument

Dim sPath As String

sPath = IO.Directory.GetParent(Application.StartupPath).ToString

oXmlDoc.Load(sPath & "\" & filename)

SBO_Application.LoadBatchActions(oXmlDoc.InnerXml)

End Sub

'Private Sub SaveAsXML(ByRef Form As SAPbouiCOM.Form)

' Dim oXmlDoc As Xml.XmlDocument

' Dim sXmlString As String

' oXmlDoc = New Xml.XmlDocument

' sXmlString = Form.GetAsXML

' oXmlDoc.LoadXml(sXmlString)

' Dim sPath As String

' sPath = IO.Directory.GetParent(Application.StartupPath).ToString

' oXmlDoc.Save((sPath & "\dispensing.srf"))

' oXmlDoc.Save((sPath & "\sizing.srf"))

' oXmlDoc.Save((sPath & "\poweblending.srf"))

' oXmlDoc.Save((sPath & "\granulation.srf"))

' oXmlDoc.Save((sPath & "\Drying.srf"))

' oXmlDoc.Save((sPath & "\Tabletcompression.srf"))

' oXmlDoc.Save((sPath & "\Cleaning.srf"))

' oXmlDoc.Save((sPath & "\Inprocess.srf"))

' oXmlDoc.Save((sPath & "\Finalproducttest.srf"))

'End Sub

Private Sub app_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

'If (FormUID = "Granulation") And (pVal.Before_Action = False) And (pVal.ItemUID = "1") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

' oForm.PaneLevel = 1

'End If

'If (FormUID = "Granulation") And (pVal.Before_Action = False) And (pVal.ItemUID = "3") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) Then

' oForm.PaneLevel = 2

'End If

'Granulation Folders Selection

If FormUID = "Granulation" Then

oForm = SBO_Application.Forms.Item("Granulation")

Select Case pVal.EventType

Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

'//************************************************************

'// Check if the event was raised by one of the Folder items

'// and change the form's pane level

'//************************************************************

If pVal.ItemUID = "1" Then

oForm.PaneLevel = 1

End If

If pVal.ItemUID = "3" Then

oForm.PaneLevel = 2

End If

If pVal.ItemUID = "5" Then

oForm.PaneLevel = 3

End If

If pVal.ItemUID = "7" Then

oForm.PaneLevel = 4

End If

End Select

End If

'Final product

If FormUID = "FinalProducttest" Then

oForm = SBO_Application.Forms.Item("FinalProducttest")

Select Case pVal.EventType

Case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED

'//************************************************************

'// Check if the event was raised by one of the Folder items

'// and change the form's pane level

'//************************************************************

If pVal.ItemUID = "22" Then

oForm.PaneLevel = 1

End If

If pVal.ItemUID = "24" Then

oForm.PaneLevel = 2

End If

If pVal.ItemUID = "26" Then

oForm.PaneLevel = 3

End If

If pVal.ItemUID = "28" Then

oForm.PaneLevel = 4

End If

End Select

End If

End Sub

End Class

Former Member
0 Kudos

Hi Thippa Reddy,

i think there is no restriction adding submenus.

try this code.. its working fine for me..

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("4352") ' production menu id

Dim sPath As String

sPath = Application.ExecutablePath

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

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP

oCreationPackage.UniqueID = "MyMenu"

oCreationPackage.String = "Manifacturing"

oCreationPackage.Enabled = True

oCreationPackage.Position = 15

oMenus = oMenuItem.SubMenus

Try

oMenus.AddEx(oCreationPackage)

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

oMenus = oMenuItem.SubMenus

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Dispensing"

oCreationPackage.String = "Dispensing"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Sizing"

oCreationPackage.String = "Sizing"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Powderblending"

oCreationPackage.String = "Powderblending"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Granulation"

oCreationPackage.String = "Granulation"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Drying"

oCreationPackage.String = "Drying"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Tabletcompression"

oCreationPackage.String = "Tabletcompression"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Cleaning"

oCreationPackage.String = "Cleaning"

oMenus.AddEx(oCreationPackage)

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Inprocessqualitycontrol"

oCreationPackage.String = "Inprocessqualitycontrol"

oMenus.AddEx(oCreationPackage)

Catch ex As Exception

sbo_application.MessageBox("InspectionMenu=" & ex.Message)

End Try

End Sub

regards,

Ganesh k

Former Member
0 Kudos

Hi Thippa Reddy,

in above coding dont consider about spath.. i mistakenly added that one.. however the coding will work fine.. sorry for that..

regards,

Ganesh k

Answers (0)