This post is about selection screen with tabs. Selection screen with tabs are not that hard to implement on ABAP and I am sure if you search online you will always get the code for it…. but just to start things ill just give the code no a basic selection screen with tabs…
| SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN END OF SCREEN 101.
SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN .
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_ebeln1 FOR zconf_stage-ebeln,
SELECTION-SCREEN END OF SCREEN 102.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 24 LINES,
mytab-prog = sy-repid.
AT SELECTION-SCREEN .
IF sy-batch = ‘X’.
now the above code is to a selection screen with tabs that you code using a report program.( this code cannot be used in module pool program )
When a customer request to a selection screen with tabs there can be 2 reasons.
1) To group a selection on one out put ( I mean the final out-put is one but selection screen can be with tabs to make things clear for e.g on SD related report the tabs can be Material selection , SO selection like wise )
2) The user requires different kind of out comes with different tabs… for e.g tab no1 to work during online operations and tab no 2 to work on background operations.
The above requirement 1 which will be totally fine with the code given on top. But the requirement 2 will be a issue when it comes to the above code. As most of the developers know on a selection screen we will always have mandatory fields. when switching between tabs the selection screen first calls the validation and then it calls the normal screen code ( as you know the validation is automatic if me make a selection option mandatory and we have no say on it ).
So in case if the user wants the functionality of the tab 2 he first has to fill all the mandatory fields on tab 1 so that the error wont occur. This was a error I had to face during my development for this there are 2 way outs
1) do the validation by your self ( draw back : you wont get the mandatory sign on the selection screen )
2) write a selection screen with tabs ( draw back : the user wont be able to save variants or this part has to be coded which will be a messy job )
for the 2nd option on above to make sure the tab switching with happen without first validating you have to do the codding as follows
| PROCESS BEFORE OUTPUT.
call SUBSCREEN SUB INCLUDING sy-repid gv_dynnr.
before call sub screen you have to call a module switch tabs.
on my case my customer wanted the variants to be there. Therefore they agreed to the validation by code where the mandatory sign is not displayed.
by Andreas Loch
If you do the validation yourself you still can have the mandatory sign. To achieve this you have to define the field as ‘recommended’ instead of required.
Example code for your report:
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name EQ ‘S_WERKS-LOW’.
screen-required = 2. “2 is recommended