Create GUI STATUS from ABAP code
I was always wondering why we cannot create GUI STATUS directly from the code as it can be done in other programming languages ( VB or C# ). I was trying to find any solution for that but every source was saying that this is not possible. But it’s only partially true. It’s true we cannot dynamically create new function codes but as we can change icons and text of existing function codes that uses dynamic text. Using this technique we can prepare an GUI STATUS with all codes using dynamic texts and then update it in the runtime.
Ok, but if you like to do it then you wouldn’t like to do it each time for each program as this makes no sense. But as you can call GUI STATUS of other program then you can create it only once and the reuse when needed. But still updating all icons, keeping in mind program name which stores GUI status would not be so handy, that’s why in my blog I’ve posted a way to do it in nice and really reusable way.
In the example below you can see than I use static methods of a class zca_ab_dynamic_gui to add new buttons, show gui statu or title bar. Thanks to its class-data we can pass dynamic text to a program which keeps GUI STATUS.
Result of this program will be:
Seems nice right? But you have to remember also about the disadvantages of this solution:
- you cannot change function code name
- reading of PAI module will not be as clear as if you would put proper names to function code
- separator does not look the same as in standard GUI
Advantage of using it:
- you don’t have to create GUI STATUS in SE41 each time, especially for small programs/reports
- you can create / update everything using ABAP
Full code of class and explanation you can find here ABAP Blog – Dynamic GUI STATUS & TITLE with ABAP code.