Editing Selections 

To display or change the structure of a logical database, choose Selections from the initial screen of the Logical Database Builder, or navigate to the selection include from another component.

The name of the selection include is DB<ldb>SEL, where <ldb> is the name of the logical database. You must not incorporate this include program in the database program using an INCLUDE statement. Instead, the runtime environment includes the selection include in the database program and the corresponding programs when it generates the logical database.

If you try to edit the selections but no selection include yet exists, the system generates one. This includes SELECT-OPTIONS statements for all of the database tables in the structure (nodes with type T). For each database table, the system proposes selection criteria for all of the fields in its primary key.

The SELECT-OPTIONS statements are commented out, and contain question marks instead of the names of the selection criteria. For each selection criterion that you want to use, you must enter the name and delete the comment character (*).

If a search help is specified for the logical database, the system also generates a corresponding PARAMETERS statement with the addition AS SEARCH PATTERN. A group box entitled Selection using search help then appears on the selection screen with input fields for the search help ID and the search string. There is also a pushbutton for complex search helps. If you choose this function, you can enter multiple selections for each field.

Finally, SELECTION-SCREEN statements are generated for dynamic selections and field selections for nodes with type T or S (if this is allowed by the structure definition).

As well as the default elements, you can use the following statements to extend the selection screen:

· The statement

SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE <node>.

allows you to define further nodes for dynamic selections. If the node has type T, you can use TABLE instead of NODE. The user can then decide at runtime the components of the node for which he or she wants to enter selections. Dynamic selections require special handling in the database program.

· The statement

SELECTION-SCREEN FIELD SELECTION FOR NODE|TABLE <node>.

allows you to define further nodes for field selections. If the node has type T, you can use TABLE instead of NODE. In an executable program, you can use a field list in the GET statement to specify which fields of the node of the logical database should be read. In the function module LDB_PROCESS, the parameter FIELD_SELECTION must be passed accordingly. Dynamic selections require special handling in the database program.

· The statements

SELECTION-SCREEN BEGIN OF VERSION <dynnr>
...
SELECTION-SCREEN EXCLUDE <f>.
...
SELECTION-SCREEN BEGIN OF VERSION <dynnr>.

allow you to create different versions of the selection screen with screen number <dynnr> less than 1000. You can hide the input fields of selection criteria or parameters as specified in <f>. This allows an executable program to work with an appropriate selection screen version.

To check the selection include DB<dba>SEL for syntax errors, choose Check on the initial screen. The system also checks the syntax of the selection include if you choose Check while editing the database program.

Suppose the logical database TEST_LDB has the following structure:

The generated default selection include would look like this:

*-----------------------------------------------------------*
* Include DBTEST_LDBSEL
* It will be automatically included into the database program
*-----------------------------------------------------------*
* If the source is automatically generated,
* please perform the following steps:
* 1. Replace ? by suitable names (at most 8 characters).
* 2. Activate SELECT-OPTIONS and PARAMETERS (delete stars).
* 3. Save source code.
* 4. Edit database program.
*
* Hint: Syntax-Check is not possible within this Include!
* It will be checked during syntax-check of database program.
*-----------------------------------------------------------*

* SELECT-OPTIONS : ? FOR LFA1-LIFNR.

* Parameter for search pattern selection (Type SY-LDB_SP):
* PARAMETERS p_sp AS SEARCH PATTERN FOR TABLE LFA1.

* SELECT-OPTIONS :
* ? FOR LFB1-LIFNR,
* ? FOR LFB1-BUKRS.

* SELECT-OPTIONS :
* ? FOR LFC1-LIFNR,
* ? FOR LFC1-BUKRS,
* ? FOR LFC1-GJAHR.

* SELECT-OPTIONS :
* ? FOR BKPF-BUKRS,
* ? FOR BKPF-BELNR,
* ? FOR BKPF-GJAHR.

* Enable DYNAMIC SELECTIONS for selected nodes :
* Enable FIELD SELECTION for selected nodes :

If the nodes LFA1 and LFB1 are defined for dynamic selections, and node LFC1 is defined for field selections, the following lines of code will also be generated:

SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE LFA1.

SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE LFB1.

SELECTION-SCREEN FIELD SELECTION FOR TABLE LFC1.

The automatically-created selection include could be modified as follows:

* Selection criteria:

  SELECT-OPTIONS SLIFNR  FOR LFA1-LIFNR.

  SELECT-OPTIONS SBUKRS  FOR LFB1-BUKRS.

  SELECT-OPTIONS SGJAHR  FOR LFC1-GJAHR.

  SELECT-OPTIONS SBELNR  FOR BKPF-BELNR.

* Self-defined parameters:

  PARAMETERS PSTIDA LIKE SY-DATUM FOR NODE BKPF.

* Dynamic selections for LFA1 and LFB1:

  SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODEE: LFA1, LFB1.

* Field selection for LFB1 and LFC1:

  SELECTION-SCREEN FIELD SELECTION FOR NODE: LFB1, LFC1.

Here, selections are chosen from the available selection criteria and are given names. An additional parameter PSTIDA is declared and linked to the node BKPF. Dynamic selections are defined for the tables LFA1 and LFB1. Field selections are defined for tables LFB1 and LFC1.