Free Selections Dialog

5
FU FREE_SELECTIONS_DIALOG ____________________________________________________ Short Text Dialog for entering dynamic selection conditions 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)

description

Free Selections Dialog

Transcript of Free Selections Dialog

Page 1: Free Selections Dialog

FU FREE_SELECTIONS_DIALOG

____________________________________________________

Short Text

Dialog for entering dynamic selection conditions

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

Page 2: Free Selections Dialog

...

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'EXPORTINGEXPRESSIONS = TEXPR.KIND = 'G'FIELD_GROUPS_KEY = QCATIMPORTINGSELECTION_ID = SELIDEXPRESSIONS = TEXPRWHERE_CLAUSES = TWHEREFIELD_RANGES = TRANGENUMBER_OF_ACTIVE_FIELDS = ACTNUMTABLESTABLES_TAB = TABSFIELDS_TAB = FIELDSEXCEPTIONSFIELDS_INCOMPLETE = 01FIELDS_NO_JOIN = 02FIELD_NOT_FOUND = 03NO_TABLES = 04TABLE_NOT_FOUND = 05EXPRESSION_NOT_SUPPORTED = 06INCORRECT_EXPRESSION = 07ILLEGAL_KIND = 08AREA_NOT_FOUND = 09INCONSISTENT_AREA = 10KIND_F_NO_FIELDS_LEFT = 11KIND_F_NO_FIELDS = 12TOO_MANY_FIELDS = 13.

Page 3: Free Selections Dialog

IF SY-SUBRC = 0.CALL FUNCTION 'FREE_SELECTIONS_DIALOG'EXPORTINGSELECTION_ID = SELIDTITLE = TITLEIMPORTINGWHERE_CLAUSES = TWHEREEXPRESSIONS = TEXPRFIELD_RANGES = TRANGENUMBER_OF_ACTIVE_FIELDS = ACTNUMTABLESFIELDS_TAB = FIELDSEXCEPTIONSINTERNAL_ERROR = 01NO_ACTION = 02NO_FIELDS_SELECTED = 03NO_TABLES_SELECTED = 04SELID_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_IDTITLEFRAME_TEXTSTATUSAS_WINDOWSTART_ROWSTART_COLNO_INTERVALSJUST_DISPLAYPFKEY

Page 4: Free Selections Dialog

ALVTREE_VISIBLEDIAG_TEXT_1DIAG_TEXT_2WARNING_TITLEAS_SUBSCREENNO_FRAMEWHERE_CLAUSESEXPRESSIONSFIELD_RANGESNUMBER_OF_ACTIVE_FIELDSFIELDS_TABFCODE_TABFIELDS_NOT_SELECTED

Exceptions

INTERNAL_ERRORNO_ACTIONSELID_NOT_FOUNDILLEGAL_STATUS

Function Group

SSEL