You can use the del statement to delete menu entries and submenus. There are three ways to do this, which we will demonstrate using the example of a menu entry in transaction VA02 (Change Sales Order).

Menu in transaction VA02
 

We remove the menu item "Loading Units and Aggregation Categories":

del M[Loading Units and Aggregation Categories]

 The item is then hidden in the menu: :

The menu item "Loading units..." is now hidden

Important for testing: It is usually necessary to call up the transaction again for testing, as SAP GUI will not otherwise display the menu entries as changed.

Instead of specifying the menu item by its text, you can use its position. To do this, first number the parent menus, i.e., 1=Sales document, 2=Edit, 3=Goto, etc. Then count the subordinate entries, including any separators: 1=Overview, 2=Header, 3=Item, 4=View, 5=Separator, 6=Loading Units and Aggregation Categories, ... Specify the numbers separated by commas:

 del M[3,6] 

When counting the menu entries, you can easily end up with an incorrect value if menu entries are already hidden: The numbers always refer to the original SAP menu. It is best to first comment out the existing del M[x] statements in your script and then count them. Alternatively, you can use the “Recording” function in the GuiXT window, which records a menu click with the correct numbers:

 

There is a third way to hide a menu item if a function key is assigned to the item. In our case, this is Ctrl+Shift+F3. Enter the number of the function key preceded by a /, adding +24 for the Ctrl key and +12 for the Shift key, i.e., in our example for Ctrl+Shift+F3, the number 24+12+3=39:

del M[/39]

Deleting the menu entry automatically hides the entry in the right-click menu for the function keys:

Function key overview in SAP GUI (right mouse button), the corresponding entry is also hidden

If there is a button in the toolbar that performs the same action as the menu item, GuiXT will also delete it. An example of this is the “Display” function in VA02, which exists in both the menu and the toolbar:

Toolbar button "Anzeigen"

 

Menu item "Display"

With

del M[/43]

both the toolbar button and the menu item are removed.

Deleting submenus also works. For example, the multi-level submenu “Output”

is removed by

del M[Output]

Submenu "Output"  removed