SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → User Dialogs → Selection Screens →Dynamic Selections
A dynamic selection is a selection condition that can be entered on a dynamically created selection screen. The associated selection screens are generated, displayed, and processed by the system function modules FREE_SELECTIONS_.... of the function group SSEL. The selection screens can be displayed separately, or integrated into the screens of other dynpros or selection screens as a subscreen. Dynamic selections can be incorporated into logical database or used in any programs.
Security Note
If used wrongly, dynamic programming techniques can present a serious security risk. Any dynamic content that is passed to a program from the outside must be checked thoroughly or escaped before being used in dynamic statements. This can be done using the system class CL_ABAP_DYN_PRG or the predefined function escape. See Security Risks of Dynamic Programming.
Dynamic Selections in Logical Databases
Logical databases can provide dynamic selections on their selections screens to specify further dynamic selection conditions for individual nodes of the logical database, in addition to the parameters and selection criteria already defined statically in the database. These dynamica conditions can then be evaluated in the database program of the logical database. Dynamic selections of a logical database can be declared simply using the addition DYNAMIC SELECTIONS of the statement SELECTION-SCREEN in the database.
The ABAP runtime environment is responsible for calling function modules to create, display, and handle dynamic selections. The selections entered by the user are passed directly to data objects of the database program and can be evaluated there. For more information, see Logical Databases - Dynamic Selections.
Note
The special addition WITH FREE SELECTIONS of the statement SUBMIT is used to pass parameters to selection screens of logical databases that provide dynamic selections. If this addition is used, the function modules mentioned above are generally also implemented.
Dynamic Selections in All Programs
In ABAP programs that work with classical dynpros, dynamic selections can be provided by the direct use of the following two function modules:
The function module FREE_SELECTIONS_INIT determines the entities for which dynamic selections are to be made. This could be, for example, database tables from ABAP Dictionary or any selection of valid fields. The result of the function module is a selection ID, which must be passed to the function module FREE_SELECTIONS_DIALOG.
The function module FREE_SELECTIONS_DIALOG can display differently configured selection screens in different formats. Users can enter dynamic selections on these selection screens for the fields provided there and, if required, can also choose fields for which they want to perform dynamic selections. If Save is chosen, the function module returns the specified selections to the caller in three different formats, which the caller can take from the following EXPORTING parameters:
For more information, see the documentation about function modules and their parameter interface.
Example
See Dynamic Selections.