The ABAP processor transfers back the content of input fields (parameters and select-options)
after returning to selection screen, so the user has the same status as by the previous selection.
The exception is the active tabstrib in the tabbed block – after returning to the selection screen,
system always shows the first tabstrip.
There are at least two solutions to change this behavior:
- use the additional hidden parameters and their transfer mechanism, which is missing for tabstrip, or
- save and the restore the last active tabstrip in memory (export/import).
What is the problem with the second export/import scenario?
It is a bit difficult/impossible to implement, because there is no event, which is fired exactly once at the start of the report (the event LOAD-OF-PROGRAM is not fired once per report call, it’s fired before processing the selection screen, also when you leaved list and the selection screen will be displayed once again). So there is no good place to code your default tabstrip selection. There is also no event, which is called after the end of the program, where you could delete or free the exported memory variables.
Here the complete example for the first scenario:
SELECTION-SCREEN BEGIN OF TABBED BLOCK tbl FOR 15 LINES.
SELECTION-SCREEN TAB (15) tbl_tab1 USER-COMMAND tab1 DEFAULT SCREEN 9001.
SELECTION-SCREEN TAB (15) tbl_tab2 USER-COMMAND tab2 DEFAULT SCREEN 9002.
SELECTION-SCREEN END OF BLOCK tbl.
SELECTION-SCREEN BEGIN OF SCREEN 9001 AS SUBSCREEN.
PARAMETERS: pa_test.
SELECTION-SCREEN END OF SCREEN 9001.
SELECTION-SCREEN BEGIN OF SCREEN 9002 AS SUBSCREEN.
SELECTION-SCREEN END OF SCREEN 9002.
PARAMETERS:
* Hidden parameters to store the last selected tab strip
pa_dynnr LIKE tbl-dynnr NO-DISPLAY,
pa_acttb LIKE tbl-activetab NO-DISPLAY.
INITIALIZATION.
* Descriptions of the tab strips
tbl_tab1 = 'First tab'.
tbl_tab2 = 'Second tab'.
AT SELECTION-SCREEN OUTPUT. " PBO
* if the last choice is saved
IF NOT pa_dynnr IS INITIAL.
* activate the last choice
tbl-dynnr = pa_dynnr.
tbl-activetab = pa_acttb.
* clear the saved choice to make it only once
pa_dynnr = ''.
pa_acttb = ''.
ENDIF.
AT SELECTION-SCREEN. " PAI
* if the list is started (F8)
IF sy-ucomm = 'ONLI'.
* save the last choice
pa_dynnr = tbl-dynnr.
pa_acttb = tbl-activetab.
ENDIF.
START-OF-SELECTION.
WRITE: / tabstrip_tbl-activetab. " show which tabstrip is active
Here the differences to check the second scenario:
SELECTION-SCREEN BEGIN OF TABBED BLOCK tbl FOR 15 LINES.
...
INITIALIZATION.
* To return to the previous selected tab strip
IMPORT tbl-dynnr FROM MEMORY ID 'TabStripScreen' .
IMPORT tbl-activetab FROM MEMORY ID 'TabStripActive'.
START-OF-SELECTION.
* To return to the previous selected tab strip
EXPORT tbl-dynnr TO MEMORY ID 'TabStripScreen'.
EXPORT tbl-activetab TO MEMORY ID 'TabStripActive'.
See other related notes on my website: