cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to disable a menu item?

Former Member
0 Kudos

Using SBO 6.50.097 SP:01 EF:07 & VB6.

I am trying to disable the Fill User Table menu item depending on the type of user signed in. For example, if the user is not a superuser then disable the menu.

I can achieve this with the following code but I was wondering if there is a simpler or better way of doing it?

***********************

Private Sub Class_Initialize()

'Assume successful sign on to correct company.

'Now get user info.

Dim sUserCode, sSuperUser As String

'Get user signed on.

sUserCode = SBO_Application.Company.UserName

Set oRecordSet = oCompany.GetBusinessObject(BoRecordset)

sSql = "Select OUSR.SuperUser From OUSR Where OUSR.USER_CODE = '" & _

sUserCode & "'"

oRecordSet.DoQuery sSql

sSuperUser = oRecordSet.Fields(0).Value

If sSuperUser = "Y" Then

bSuperUser = True 'Boolean declared elsewhere.

Else

bSuperUser = False

End If

End Sub

Private Sub SBO_Application_MenuEvent(pVal As SAPbouiCOM.IMenuEvent, BubbleEvent As Boolean)

If bSuperUser = False Then

If pVal.BeforeAction = True Then

'Fill User Table sub-menu UIDs start with "512".

If Left(pVal.MenuUID, 3) = "512" Then

'Do nothing when user clicks on menu item.

BubbleEvent = False

End If

End If

End If

End Sub

***********************

I was hoping to just use something like

If sSuperUser = "N" Then

SBO_Application.Menus.Item("51201").Enabled = False

End If

replacing "51201" with the MenuUID for Fill User Table, but this gives an error saying the menu item not found?

Any help is much appreciated.

Regards,

Andrew.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The menu collection is a zero based collection.

For example:

in order to disable the "Sales - A/R" menu you'll need the following code -

<i>oApp.Menus(4).SubMenus(3).Enabled = False</i>

<b>oApp</b> - the Application object

<b>Menus(4)</b> - represent the Mudule menu item (will be best to go over the collection and look for the string "&Module")

<b>SubMenus(3)</b> - represent the "Sales - A/R" menu item

once again - in the long way:

<i> Dim oMenu As SAPbouiCOM.MenuItem

Dim oMenus As SAPbouiCOM.Menus

Set oMenus = m_App.Menus

Set oMenus = oMenus.Item(4).SubMenus

Set oMenu = oMenus.Item(3)

oMenu.Enabled = False</i>

it is recommended to view the application object and its collections using the debug mode watch.

Regards,

Yaniv G.

SDK Consultant,

SAP Manage Israel.