SAP Function FREE_SELECTIONS_INIT - Initialize dynamic selection: Declare permitted tables ...

Parameter Reference Type Length Default Optional Text
ALV 0 X Internal Use
CURR_QUAN_PROG SYST-REPID C 40 SY-CPROG X Program for fetching currency reference
CURR_QUAN_RELATION SSCR_CURR_QUAN_T 0 X Assignment quantity field -> currency key field.
EXPRESSIONS RSDS_TEXPR 0 X Initial selections
FIELD_GROUPS_KEY RSDSQCAT u 43 X Selection view key
FIELD_RANGES_INT RSDS_TRANGE 0 X Initial Selections in Form of Ranges Tables
KIND 0 'T' X Type of field list
RESTRICTION SSCR_RESTRICT_DS 0 X Option restrictions of individual selections

Parameter Reference Type Length Text
EXPRESSIONS RSDS_TEXPR 0 Initial selections
FIELD_RANGES RSDS_TRANGE 0 Selections in form of RANGES tables
NUMBER_OF_ACTIVE_FIELDS SYST-TFILL I 4 Number of fields with selections
SELECTION_ID RSDYNSEL-SELID C 8 Identification for FREE_SELECTIONS_DIALOG
WHERE_CLAUSES RSDS_TWHERE 0 Selections in form of WHERE clauses

Parameter Reference Length Optional Text
ALV_QINFO LVC_S_QINF 222 X Internal Field
EVENTS RSDSEVENTS 71 X Events for which control is required
EVENT_FIELDS RSDSEVFLDS 64 X Fields for field-specific events
FIELDS_NOT_SELECTED RSDSFIELDS 76 X Kind F: Fields not initially selected
FIELDS_TAB RSDSFIELDS 76 X Preselect fields
FIELD_DESC FLDCONVERT 84 X Description of non-Dictionary fields
FIELD_TEXTS RSDSTEXTS 90 X Own selection texts
NO_INT_CHECK RSDSTABS 120 X Fields for which the interval check is to be deactivated
TABFIELDS_NOT_DISPLAY RSDSFIELDS 76 X Child T: Hide Fields
TABLES_TAB RSDSTABS 120 X Desired tables

Exception Text
AREA_NOT_FOUND Invalid key FIELD_GROUPS_KEY
AREA_NO_FIELD Selection view has no fields
DUP_EVENT_FIELD Field doubled in EVENT_FIELDS
DUP_FIELD Field doubles in FIELDS_TAB
EXPRESSION_NOT_SUPPORTED Expression not (yet) supported
FIELDS_INCOMPLETE Only PRIM_FNAME filled
FIELDS_NO_JOIN Field assignment without join
FIELD_ILL_TYPE Non-allowed field type
FIELD_NOT_FOUND Dictionary field not found
FIELD_NO_TYPE No field type in the field description
ILLEGAL_KIND KIND not equal to T,G,F or: G without P_RSDSQCAT
INCONSISTENT_AREA Inconsistent selection view
INCORRECT_EXPRESSION Incorrect logical expression
KIND_F_NO_FIELDS KIND = F, but no field passed
KIND_F_NO_FIELDS_LEFT KIND = F, but no field left after cleanup
NODE_NOT_IN_LDB Node not part of logical database
NO_TABLES Table P_TABLES is empty
TABLE_NOT_FOUND A table from P_TABLES was not found
TOO_MANY_FIELDS Too many entries in FIELDS_TAB

Functionality
Initialization for entering dynamic selections using the functionmodule FREE_SELECTIONS_DIALOG.
In the simplest case, the function module receives information about
the set of fields for which dynamic selections should be possible, and
returns a selction ID, which itself is passed to the function module
FREE_SELECTIONS_DIALOG.
The function module can be called more than once during a transaction(with different field sets each time), and it returns a new selectionID each time. This makes it possible to run dialogs for different setsof fields within the same transaction.
You must (or can) pass the following details to the function module:
The type of field set (KIND parameter):
T: All fields from the list of tables (P_TABLES)
G: All of the fields in a selection view (can be maintained in teh ABAPWorkbench). The FIELD_GROUPS_KEY parameter contains the key.
F: Simple selection of fields (passed in the table FIELDS_TAB).
If the field TABLENAME is filled, the system looks for the field in theABAP Dictionary. If TABLENAME is empty, FIELDNAME can be any field. Inthis case, you must provide a field description for the remainingfields in FIELD_TAB or FIELD_DESC (see below).
The tables for which the function module FREE_SELECTIONS_DIALOG shouldcreate WHERE clauses (TABLES_TAB).
TABLES_TAB may only be empty if the type is "F". In this case, thefunction module uses all of the tables containing at least one fieldfrom FIELDS_TAB.
In TABLES_TAB you can also specify table joins. In this case, the fieldPRIM_TAB contains the name of the join, SEC_TAB contains the name ofone of its constituent tables. The user sees (at most) the names of theconstituent tables, but the WHERE clauses returned byFREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG also contain entriesfor the joins. If a field in a join has a different name to thecorresponding field in the database table, you must specify this usingthe PRIM_FNAME (field name in join) and SEC_FNAME (field name inconstituent table) fields, so that the WHERE clauses for the join havethe right field names. If PRIM_FNAME is empty but SEC_FNAME contains avalue, this means that the corresponding field does not occur in thejoin. The system then does not generate WHERE claues for this field inthe join. Normally (that is, where you do not use joins), only thePRIM_TAB field is filled.
A set of preselected fields (table parameter FIELDS_TAB). This isoptional except with type "F".
The system deletes all fields from this field list that do not belongto one of the tables listed in TABLES_TAB (exception: Type "F" - seeabove).
If the field set consists of a selection view (type "G") and FIELDS_TABis empty, the system uses the preselected fields from the selectionview.
If preselected fields exist after the function module has run, thefunction module FREE_SELECTOINS_DIALOG opens the selection screen forentering selections for the preselected fields. Otherwise, a fieldselection screen appears.
For types "G" and "T", FIELDS_TAB defines the set of preselectedfields. However, for type "F", it determines the entire set ofavailable fields. To make a preselection in this case, you can fill thefollowing parameters:
FIELDS_NOT_SELECTED: for type "F": List of the fields you do not wantto offer for selection. The next call of FREE_SELECTIONS_DIALOG thenonly offers fields that are NOT listed in FIELDS_NOT_SELECTED. Fieldsfrom FIELDS_NOT_SELECTED are only available with the "New fieldselection" function. This allows you to offer a comprehensive fieldlist without filling up the initial screen of FREE_SELECTIONS_DIALOGtoo much.
Field descriptions for fields not from the ABAP Dictionary (only KINDF)for which FIELDS_TAB is insufficient (FIELDS_DESC).
If a field has an empty table name from FIELDS_TAB but an entry inFIELD_DESC, the FIELD_DESC name is used. If there is no entry, theinformation is taken from FIELDS_TAB. You must specify at least thefield type. If further information (such as the length)is missing, thesystem uses default values.
A selection set you hvae already generated, passed as an object withtype RSDS_TEXPR (type pool RSDS) to the parameter EXPRESSIONS(optional).
This allows you to redisplay "old" selections in the first dialog afterthe initialization call.
Different selection texts (FIELD_TEXTS). Here you can overwrite thedefault texts stored in the ABAP Dictionary, and pass selection textsfor fields that do not have an ABAP Dictionary reference.
A list of events on the selection screen at which the caller wants toregain control (EVENTS). This list contains:
- The events the caller wants to handle (EVENT field)
- The FORM routine that should be called when the event occurs
(PROG and FORM fields).
For information about filling the EVENT field and the interfacestructure that the called routines must have, see the documentation forthe EVENTS parameter.
A list of field names (can also be given generically), for the eventsfrom the EVENTS table that depend on individual selections (such as ATSELECTION-SCREEN ON ) which the caller wants to handle(EVENT_FIELDS). Specify the table name and field name (if a field doesnot have an ABAP Dictionary reference, specify only the field name),and select the events at which the caller should regain control.
Assignment of amount fields to currency or unit fields (CURR_QUAN_PROGand CURR_QUAN_RELATION fields. This ensures that the fields will beformatted appropriately for the currency or unit.
Rules for the permitted signsn and selection options (RESTRICTIONparameter). This corresponds to the function moduleSELECT_OPTIONS_RESTRICT for 'normal' selection screens.
The function module has the following output:
RESET N1
The selection ID (parameter SELECTION_ID).
This serves as an identifier. You must pass it to the function moduleFREE_SELECTIONS_DIALOG.
The selections passed in the EXPRESSIONS parameter, without any of theselections that are not for fields in a table listsed in TABLES_TAB(export parameter EXPRESSIONS).
The above in the form of WHERE clauses that can be passed to aSELECT statement (export parameter WHERE_CLAUSES,type RSDS_TWHERE from type pool RSDS).
The above in the form of ranges tables that can be passed to aSELECT statement (IN clauses) (export parameterFIELD_RANGES, type RSDS_TRANGE from type pool RSDS).
The number of fields for which selections are actually available(export parameter NUMBER_OF_ACTIVE_FIELDS).

Description
Allows you to store selections entered during an earlier call toFREE_SELECTIONS_DIALOG and pass them to FREE_SELECTIONS_INIT. The nexttime FREE_SELECTIONS_DIALOG is called, the old selections aredisplayed.
These selections are returned apart from any that belong to tables nolonger defined (parameter TABLES_TAB).

Description
Returns the selections specified in the import parameter EXPRESSIONS inthe form of ranges tables for each field concerned. The parametermust(!) be of type RSDS_TRANGE (==> type pool RSDS).
You can pass the individual ranges to the IN operator in SELECT, CHECKand IF.

Description
Contains the number of fields for which selections have actually beendefined (for each import parameter EXPRESSIONS, if necessary minus thefields that do not belong to any of the tables in TABLES_TAB.

Description
Each time you call the function module FREE_SELECTIONS_DIALOG, you mustinclude one of the selection IDs returned by a previous call ofFREE_SELECTIONS_INIT. In the course of a transaction, it is thuspossible to run selection entry dialogs for different field lists.

Description
This object (of type RSDS_TWHERE ==> type pool RSDS) only containsWHERE clauses, if the import parameter EXPRESSIONS includes expressionsfor the function module. From these expressions, the WHERE clauses aregenerated in WHERE_CLAUSES.
Whenever this parameter is passed, the current currency (along with itscorresponding number of decimal places) is retrieved from theappropriate work area in the program and supplied to all amount fieldsthat have a currency key field (default program: the main program forthe transaction).
This also holds ture for quantity fields and unit fields.

Description
Assignment of currency key field or unit field to an amount field or aquantity field, where all the fields are in the dynamic selection fieldselection.
The purpose is to make, for example, both the amount field and thecurrency key field available on the selection screen, and the format ofthe amount field reflect the currency key entered by the user (say, twodecimal places for US dollars, no decimal places for Italian lire). TheRESTRICTION parameter can be used to limit the user's currency keyinput to a single currency key. Additionally, a default value(component DEF_VALUE) can be specified, which is supplied if the userdoes not select the currency key field or unit field (that is, thefield does not appear on the selection screen)
Example:
FIELDS_TAB contains fields SBOOK-FORCURAM (amount field) andSBOOK-FORCURKEY (currency key field).
To ensure the format of the user input in SBOOK-FORCURAM reflects theuser's input in SBOOK-FORCURKEY where the currency appears on theselection screen, and that otherwise the format is suitable for USdollars:
TYPE-POOLS SSCR.
DATA CURR_QUAN TYPE SSCR_CURR_QUAN.
DATA CURR_QUAN_T TYPE SSCR_CURR_QUAN_T.
MOVE: 'SBOOK' TO CURR_QUAN-TABLENAME,
'FORCURAM' TO CURR_QUAN-FIELDNAME,
'SBOOK-FORCURKEY' TO CURR_QUAN-REFFIELD,
'USD' TO CURR_QUAN-DEF_VALUE.
APPEND CURR_QUAN TO CURR_QUAN_T.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
...
CURR_QUAN_RELATION = CURR_QUAN_T
...
See also: parameter CURR_QUAN_PROG.

Description
Allows you to store selections entered during an earlier call toFREE_SELECTIONS_DIALOG and pass them to FREE_SELECTIONS_INIT. The nexttime FREE_SELECTIONS_DIALOG is called, the old selections aredisplayed.
These selections are returned apart from any that belong to tables nolonger defined (parameter TABLES_TAB).

Description
For KIND = 'G'. You can create and maintain selection views in theDevelopment Workbench.

Description
T: All fields of the tables specified in TABLES_TAB.
G: A selection view (key in FIELD_GROUPS_KEY)
F: The fields passed in FIELDS_TAB.

Default
T

Description
You use this parameter to restrict the permitted sign and/or permittedselection options for some or all selections. Possible uses are, forexample, to ensure that for certain selections interval entries are notsupported, or that for certain selections the option of excludingvalues is not available. Another possible use is to ensure that theuser cannot go to the multiple selection screen for some selections.The overall effect is to simplify working in the selection screen andto prevent inappropriate entries being made. For example, this methodcan be used to ensure that only one single currency can be specified ina currency key field (see also parameter CURR_QUAN_RELATION).
Function module SELECT_OPTIONS_RESTRICT provides the same functionalityfor "regular" selection screens.
The structure of parameter RESTRICTION (type SSCR_RESTRICT_DS from typepool SSCR) corresponds to that of parameter RESTRICTION fromSELECT_OPTIONS_RESTRICT, which is type SSCR_RESTRICT. The onlydifference between the two types is that the identification of anSSCR_RESTRICT selection comprises a name, whereas for anSSCR_RESTRICT_DS selection it is a pair made up of a table name and afield name. The documentation for SELECT_OPTIONS_RESTRICT tells you howto fill parameter RESTRICTION.

Description
Tells the system those events on the selection screen over which thecaller wants control.
The event itself is encoded in the EVENT field.
Key:
- O: AT SELECTION-SCREEN OUTPUT
- A: AT SELECTION-SCREEN
- S: AT SELECTION-SCREEN ON
- E: AT SELECTION-SCREEN ON END OF
- 1: AT SELECTION-SCREEN ON HELP-REQUEST FOR
- 4: AT SELECTION-SCREEN ON HELP-REQUEST FOR -LOW/HIGH
For events belonging to a special selection, you can use theEVENT_FIELDS parameter to specify for which selections the system is topass back control to the caller.
In the PROG and FORM fields, you specify the program name and the nameof a FORM that are to be called in that event. werden sollen.
The specified routines must have the following interfaces:
EVENT O:
- Table parameter with the structure RSSELDYN. This parameter containsall currently active selections (those that are active while theselection screen is being processed. The first line of a selectioncontains the current contents of the header line. The rest of itcontains the lines of the selection itself.
- Table parameter with structure RSFLDNUM
This parameter contains the assignme of the selection name (table andfield names, or just the field name for a field without an ABAPDictionary reference) to the screen modification group (SCREEN-GROUP1)for the selection. This allows you, for example, to hide the HIGHfield.
EVENT A:
- as EVENT O
EVENT S:
- Table parameter with structure RSSELDYN.
This parameter contains the last selection to be processed. In thiscase, the split into header line and contents corresponds to the splitin the selection itself.
- USING parameter with structure RSDSFLDNUM.
As in EVENTs O and A, except that here, only information about thecurrent selection is passed (this is not a table parameter).
EVENT E:
- as EVENT S
EVENT 1:
- USING parameter with structure RSDSFLDNUM.
The same as EVENT S: The parameter contains the ID of the selection forwhich the documentation is to be displayed.
EVENT 4:
- USING parameter with structure RSDSFLDNUM.
as in EVENT 1.
- USING parameter with structure RSDSF4INFO
This currently shows whether F4 was pressed in the LOW or HIGH field(in the field FOCUS).
- USING parameter for the ctual contents.
When called, this contains the current contents of the field on whichF4 was pressed. Afterwards, the screen field is filled by the value(which may have been changed).

Description
List of the selections for which the control should be passed back tothe called in selection-specific events (EVENTs S, E, 1, 4 in parameterEVENTS).
You can specify field names generically here (table name *: all fields,table name not *, but all fields *: All fields in the specified table.Emptyp table name means fields without an ABAP Dictionary reference).You can also enter individual fields. The system always takes the mostspecific information in ambiguous cases.
In each line, you can select which events should be handled:
AT_ON: AT SELECTION-SCREEN ON
AT_ON_END: AT SELECTION-SCREEN ON END OF
F1: AT SELECTION-SCREEN ON HELP-REQUEST FOR
F4: AT SELECTION-SCREEN ON VALUE-REQUEST FOR
-LOW/HIGH

Description
This parameter is interpreted only where KIND = 'F'. The selectionslisted are not displayed when FREE_SELECTIONS_DIALOG is next called,but can be activated by choosing "New field selection".

Description
The meaning of this table parameter depends on the type of field list(import parameter KIND).
If KIND = 'T' or KIND = 'G', the listed fields are a preselection offields. When FREE_SELECTIONS_DIALOG is first called, the dialogbranches at once to the input screen for the preselected fields (here,fields that do not belong to any of the desired tables are deleted).
If KIND = 'F', FIELDS_TAB simply contains the list of fields for whichdynamic selections are required. In this case, you can use parameterFIELDS_NOT_SELECTED to exclude fields from the preselection.

Description
To enable dynamic selection for fields without dictionary references,you have to specify field attributes for the fields. In ordinary casesyou can do this in table parameter FIELDS_TAB. If necessary, you canspecify detailed descriptions in FIELD_DESC.

Description
For selections with dictionary reference the selection text is normallyfetched from the dictionary, and for selections without dictionaryreference the field name is displayed. In either case you can overwriteby making an entry in FIELD_TEXTS.

Description
Similarly to the function moduleRS_SELOPT_NO_INTERVAL_CHECK, youcan pass the names of the fields, for which the interval check is to bedeactivated, in this table. This specification always refers to thereturned selection ID - that is, the interval check is switched off forthe specified fields wheneverFREE_SELECTIONS_DIALOG is called withthis selection ID.
Table contains the names of those tables for which enhanced selectionsare supported. All parts should be entered with joins (field SEC_TAB)as well as - if available - all field names form the join that differfrom those in the original table.