Web DynPro ABAP – Context Menu Not Showing?

For the developers and programmers among us adding a context menu to an application is a fairly basic requirement of many pieces of software.  Adding a context menu in Web DynPro looks on the face of it to be an extremely easy process – and it is, as long as you don’t forget anything ;).

Although there are a fair few guides on the Internet that explain how to add a context menu in Web DynPro they all seem to miss out one important detail, which without knowing it, means that your context menu fails to appear at all and can make the process extremely stressful.

That’s why I’m sharing this top tip with you today.  Firstly, follow one of the many guides available such as this one.  And while using this or another guide don’t forget our…..

Context Menu Top Tip

Firstly, note that whether you are implementing a dynamic or a static context menu in your application this tip applies to both.

In newer versions of the SAP GUI, according to reports at least from version 7.00 – maybe even earlier, there is a new option to add a context menu to most User Interface elements in the properties tap (i.e. this no longer has to be done programmatically).

However, most, if not all guides seem to have missed out the fact that as well as setting the context menu you want to use in the properties menu you also have to change the ‘ContextMenuBehaviour‘ property to ‘Provide’ rather than the default setting of ‘Inherit’.

As the name suggest, if you leave this on ‘Inherit’ you will be left puzzled by the fact that no matter what you do, you context menu simply won’t appear – only the default one will.

When this property is pointed out, it becomes fairly obvious – however it can be frustrating until you figure it out and waste time!

Conclusion

The conclusion to all this is that it is frustrating but understandable.  Technically however, I think that the SAP GUI could help you out by ‘defaulting’ the ContextMenuBehaviour property to Provide when you actually pick a context menu in the properties.

However, until that happens, every time you set the context menu on a UI element, don’t forget to set the ContextMenuBehaviour property as well!

Image: mynetx.