Setting the GUI Status for a Selection-Screen
In dialog programming, you may already be familiar with the setting of the PF-STATUS (known as the GUI Status) prior to calling a screen. Usually, the code looks something like this:
set pf-status ‘STATUS_2000’.
call screen ‘2000’.
I recently discovered that this does not work at all when calling a selection screen.
Here was my non-working code:
set pf-status ‘STATUS_2100’.
call selection-screen ‘2100’.
Even if you walk through the code using the debugger, the statement appears to execute, but the GUI status that is presented when selection-screen 2100 is called is the GUI status that was already running prior to calling the new selection-screen. So, when the new selection-screen is called, the application buttons do not match the new selection-screen.
The solution, I discovered, is that you need to call SAP function module RS_SET_SELSCREEN_STATUS, and it needs to be called in the selection-screen output event. Here is my working code:
at selection-screen output.
case sy-dynnr.
when ‘2100’.
call function ‘RS_SET_SELSCREEN_STATUS’
EXPORTING
P_STATUS = ‘STATUS_2100’
TABLES
P_EXCLUDE = exclude.
when ‘2200’.
call function ‘RS_SET_SELSCREEN_STATUS’
EXPORTING
P_STATUS = ‘STATUS_2200’
TABLES
P_EXCLUDE = exclude.
endcase.
So now, when a selecion-screen is called (as in CALL SELECTION-SCREEN ‘2100’.), the PBO event
for that selection-screen will take us to the AT SELECTION-SCREEN OUTPUT event code,
and will set the GUI status properly.
Thanks for this hint… however I got a question. After setting the GUI Status of the selection screen to a custom one will we also get the Execute button present even if it is not defined in the custom GUI Status? Or should we define the execute button in the GUI Status ourselves?
I found another way to change the GUI Status. I only needed to add one button on the selection Screen. I copied the Original GUI Status for the Selection Screen and copied it as a custom one and then modified it by adding my own button…
Thanks alot.