SAP GUI Context Menu Inaccessable

1.5k Views Asked by At

I have a SAP GUI interface that works except for the context menus. In this particular case we are trying to automate adding attachments to equipment masters. The button for this is in a context menu in the title bar.

When I do a Script Recording I get this line for selecting the context menu. This works fine if you run it with the transaction opened.

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"

When I add this into the c# code for editing the equipment master I get the error 'Method got and invalid argument'.

GuiShell objectShell =  (GuiShell)SapSession.FindById("wnd[0]/titl/shellcont/shell");

objectShell.SelectContextMenuItem("%GOS_PCATTA_CREA");

I am not sure how to get the proper Function Code if it is not '%GOS_PCATTA_CREA'. This is the only object type that we have not been able to manipulate.

1

There are 1 best solutions below

0
On

After poking at this for several days I figured it out.

The Shell holds a tool bar, seems there is some translation in the VBA code that allows direct access to the tool bar in the shell that C# does not.

The code that works is below. It will open the context menu and then open the attachments dialog.

GuiToolbarControl myToolBar = (GuiToolbarControl)SapSession.FindById("wnd[0]/titl/shellcont/shell");

myToolBar.PressContextButton("%GOS_TOOLBOX");

myToolBar.SelectContextMenuItem("%GOS_PCATTA_CREA");