Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
How often developers use buttons in user interfaces? Is it easy by comparison with Web dynpro & Fiori elements to create a simple one in SAP gui? Let's refresh in our memory well known ways of making them. In classical (may I say old-fashioned?) ABAP there are several ways to make buttons dynamically:





  • SET PF-STATUS ... EXCLUDING


Usually if there are just few of actions associated with buttons ABAP-ers could create all of them and exclude unnecessary ones. Also we have ability to create several PF-STATUS and choose the desired by condition. It could be very helpful if you have a PF-STATUS based on standard ALV and most of the positions in it are already occupied by standard actions like 'Select All' 'Unselect all' etc. That's why personally I prefer to create a ALV toolbar instead of PF-STATUS.

  • SELECTION-SCREEN FUNCTION KEY


At selection screens we have ability to create up to 4 buttons at a time. Icons & texts could be set programmatically. But if use LDB like PNPCE or PCH there are would no vacant place for new button.

  • SELECTION-SCREEN - PUSHBUTTON (or ordinary button in the screen painter)


Is very similar to a previously described FUNCTION KEY approach with additional advantage to place them anywhere you want.




What all 3 approach have in common? I think you already noticed, they have explicit ABAP language declarations and you cannot create them by "pure" code.

You could disagree with me, but all listed above ways of creating buttons have some kind of restrictions. Since special language constructions are usually static by their essence and they are tightly coupled with the screens they belong to.

Loose coupling in the other hand can bring more flexibility and allows us to create universal UI for different purpose. And in SAP gui there is an good example of that kind of flexible design.


GOS buttons created by CL_GUI_TOOLBAR


Usually well known (from 7.00 I guess) GOS menu were used for file attachments. But wait could we use CL_GUI_GOS_CONTAINER class for our own purpose? I think we could. Why not? And made small class for this goal.




 ZCL_EUI_MENU



 

The class can create buttons like this

image

 

or hierarchical menus like this

image

as an ordinary gos menus.

 

for event handling you have to pass an object to ZCL_EUI_MENU constructor. And all methods


'for event FUNCTION_SELECTED OF cl_gui_toolbar' will be triggered in it.


 




A dynamic toolbar like this would be probably helpful just in a certain circumstances. Full pf-status or dynamically changed menus could be good cases to try this class. But I hope that standard CL_GUI_GOS_CONTAINER class (just recently discovered by me) would give you food for thought about casual things like buttons.

 

Additional information about the wrapper class available here.

If you have an ALV & don't like PF-STATUS maybe ALV toolbar will be your choice.
7 Comments