Free Selections Dialog
Free Selections Dialog
Functionality
Dialog for entering dynamic selections. The simplest procedure is where a selection screen appears when you call the function module. If you enter your selections and press Copy, the function module returns the selections to the caller in three different forms. The essential input parameter (SELECTION_ID) is the selection ID returned by the previous call to FREE_SELECTIONS_INIT. It is used to identify this special set of dynamic selections so that, during a transaction, you can manage several sets of dynamic selections that can be redisplayed one after the other for maintenance. The second input parameter TITLE can contain the selection screen title. The third input parameter STATUS can include the number of a GUI status for the selection screen (see documentation of the parameter "STATUS"). If a field selection is made when you call FREE_SELECTIONS_INIT or following an earlier call to FREE_SELECTIONS_DIALOG, you immediately see the selection screen for entering the selections for the chosen fields. From here, you can then make a new selection - as long as this is defined by this selection ID. If no fields are selected, you first see the field selection screen and can then branch to the selection screen. The function module returns 5 objects (if desired): 1. A table of the chosen fields (FIELDS_TAB). 2. The entered selections in the form of logical expressions (export parameter EXPRESSIONS, type RSDS_TEXPR ==> type pool RSDS). You can save this form and pass it to the function module FREE_SELECTIONS_INIT again later, so that the old selections are displayed at once when you call FREE_SELECTIONS_DIALOG. 3. The same in the form of WHERE clauses that can be passed directly to a SAP SELECT statement (export parameter WHERE_CLAUSES, type RSDS_TWHERE ==> type pool RSDS). 4. The same in the form of RANGES tables that can be passed directly to a SAP SELECT statement (IN operator) (export parameter FIELD_RANGES, type RSDS_TRANGE ==> type pool RSDS) 5. The number of fields for which you can actually enter selections (this can be smaller than the number of entries in FIELDS_TAB).
Example The field string QCAT (structure RSDSQCAT) contains the key of a selection view: ORIGIN: 'CUS' (customer) DBNA: empty (no logical database used) NAME: CHARLY
... TABLES: ABCD, XYZW. TYPE-POOLS RSDS. DATA TEXPR TYPE RSDS_TEXPR. DATA TWHERE TYPE RSDS_TWHERE. DATA TRANGE TYPE RSDS_TRANGE. DATA DS_CLAUSES TYPE RSDS_WHERE. DATA BEGIN OF TABS OCCURS 10. INCLUDE STRUCTURE RSDSTABS. DATA END OF TABS. DATA BEGIN OF FIELDS OCCURS 10. INCLUDE STRUCTURE RSDSFIELDS. DATA END OF FIELDS. DATA SELID LIKE RSDYNSEL-SELID. DATA ACTNUM LIKE SY-TFILL. DATA TITLE LIKE SY-TITLE VALUE 'My title'. ... (Fill tables TABS and FIELDS, ... e.g. TABS should contain the tables ABCD and XYZW, ... FIELDS the fields ABCD-F1, ABCD-F2 and XYZW-F0) CALL FUNCTION 'FREE_SELECTIONS_INIT' EXPORTING EXPRESSIONS = TEXPR. KIND = 'G' FIELD_GROUPS_KEY = QCAT IMPORTING SELECTION_ID = SELID EXPRESSIONS = TEXPR WHERE_CLAUSES = TWHERE FIELD_RANGES = TRANGE NUMBER_OF_ACTIVE_FIELDS = ACTNUM TABLES TABLES_TAB = TABS FIELDS_TAB = FIELDS EXCEPTIONS FIELDS_INCOMPLETE = 01 FIELDS_NO_JOIN = 02 FIELD_NOT_FOUND = 03 NO_TABLES = 04 TABLE_NOT_FOUND = 05 EXPRESSION_NOT_SUPPORTED = 06 INCORRECT_EXPRESSION = 07 ILLEGAL_KIND = 08 AREA_NOT_FOUND = 09 INCONSISTENT_AREA = 10 KIND_F_NO_FIELDS_LEFT = 11 KIND_F_NO_FIELDS = 12 TOO_MANY_FIELDS = 13.
IF SY-SUBRC = 0. CALL FUNCTION 'FREE_SELECTIONS_DIALOG' EXPORTING SELECTION_ID = SELID TITLE = TITLE IMPORTING WHERE_CLAUSES = TWHERE EXPRESSIONS = TEXPR FIELD_RANGES = TRANGE NUMBER_OF_ACTIVE_FIELDS = ACTNUM TABLES FIELDS_TAB = FIELDS EXCEPTIONS INTERNAL_ERROR = 01 NO_ACTION = 02 NO_FIELDS_SELECTED = 03 NO_TABLES_SELECTED = 04 SELID_NOT_FOUND = 05. IF SY-SUBRC = 0. CLEAR DS_CLAUSES. MOVE 'ABCD' TO DS_CLAUSES-TABLENAME. READ TABLE TWHERE WITH KEY DS_CLAUSES-TABLENAME INTO DS_CLAUSES. SELECT * FROM ABCD WHERE ... AND (DS_CLAUSES-WHERE_TAB). ... ENDIF. ENDIF. The selection ID returned by the function module FREE_SELECTIONS_INIT is thus passed to the function module FREE_SELECTIONS_DIALOG. Since FREE_SELECTIONS_INIT has already received a table with selected fields, FREE_SELECTIONS_DIALOG branches immediately to the selection screen for the fields ABCD-F1, ABCD-F2 and XYZW-F0. Now the user can enter the selections, make a new field selection etc. The result is returned and can then, for example, be passed (in the form of TWHERE) to a SELECT statement. Here, the line of TWHERE belonging to the table ABCD (for example) is read into the object DS_CLAUSES (type RSDS_WHERE = line type of RSDS_TWHERE) and the table DS_CLAUSES-WHERE_TAB (which contains the actual WHERE clause) is passed on to the SELECT statement.
Parameters
SELECTION_ID TITLE FRAME_TEXT STATUS AS_WINDOW START_ROW START_COL NO_INTERVALS JUST_DISPLAY PFKEY
ALV TREE_VISIBLE DIAG_TEXT_1 DIAG_TEXT_2 WARNING_TITLE AS_SUBSCREEN NO_FRAME WHERE_CLAUSES EXPRESSIONS FIELD_RANGES NUMBER_OF_ACTIVE_FIELDS FIELDS_TAB FCODE_TAB FIELDS_NOT_SELECTED
Exceptions
INTERNAL_ERROR NO_ACTION SELID_NOT_FOUND ILLEGAL_STATUS
Function Group
SSEL