I have a number of ABAP reports with similar but complicated customized selection screen (i.e. implemented using SELECTION-SCREEN statement). I would like to "package" the codes for SELECTION-SCREEN in a common routine in an include program, so that all my reports can just use it (instead of all reports duplicating the same selection screen codes). Any changes to the selection screen can be made through the single source.
However, an error :
Within FORM routines and function modules, the SELECTION-SCREEN statement is not allowed.
Is there any other way to accomplish this goal ? Thank you.
The only way to be able to re-use a screen, selection-screen or otherwise, is when the screen is a subscreen.
Have one report program where you have got the selection screen defined as follows -
selection-screen begin of screen 1010 as subscreen.
parameters : test like t001-mandt.
selection-screen end of screen 1010.
Have a second program with normal screen, which has a subscreen area.
data : repid type syrepid,
dynnr type sydynnr.
repid = 'ZTEST'.
dynnr = '1010'.
call screen 100.
Screen 100 has a subscreen area and its flow logic will be something like this -
PROCESS BEFORE OUTPUT.
call subscreen subscreen_area_name including repid
PROCESS AFTER INPUT.
call subscreen sub1.
Now, each time you make a change to the selection-screen's definition in program ZTEST, the change will always be reflected in all the other programs which are using it as their subscreen.
1. I had faced same problem.
2. what i did :
a) create two programs (Both Type 1 )
b) In Prog1 Define Selection Screen and INITIALIZATION
C) In Prog2 U can use events. (Prog2 can be Many programs in which u INCLUDE PROG1 at the top)
D) Use Report Statement in Prog1 (And Not in Prog2 : prog2 will have include prog1 at top, and then events)
3. To make it more better.
a) in Prog1 use SELECTION-SCREEN BEGIN OF BLOCK
b) In Prog2 U can define additional parameters/screen elements
to ENHANCE your selection screen (if required)
It works fantastic for me.
Message was edited by: Amit Mittal