ABAP Keyword Documentation → ABAP - Reference → Obsolete Language Elements → Obsolete Processing of External Data → Logical Databases (Obsolete) → Logical Databases - Components → Logical Databases - Further Elements
Logical Databases - Associated with Search Helps
A logical database can be associated with a suitable search help. The best type of search help for a logical database depends on the content of the database. For example, if a logical database is created to read vendor records, one output field of the search help must be the vendor number. The logical database is provided with the content of the search help output fields and uses it to perform the actual reads on the database tables.
To enable the user to use the search help, the a special parameter with the addition
AS SEARCH PATTERN must be declared in the selection include. The selection
screen then displays the Selection by Search Help box, including input fields
for the search help ID and the search string. There is also a pushbutton for complex search helps and multiple selection is permitted for every individual field.
The runtime environment is responsible for interpreting the user input on the selection screen and reading
the value list from the database. These rows are passed to the database program in the internal table
ldb_sp and the subroutine
put_ldb_sp is called
for the root node instead of the subroutine
is the name of the logical database. The value list in the internal table
is used to enable this subroutine to read the actual data and trigger the event
for the root node using the statement
PUT. It is often useful to call the
put_node for the root node from
The subroutine then selects the data and triggers the associated
PUT. The structure of the internal table
and other automatically generated tables is displayed as a comment in the database program source code. The source code also contains documentation about how to use these tables.
The options provided by dynamic selections and
field selections should also be exploited when
using search helps to access the database. Search helps can also be used to improve performance. The
sp_tables plus the structure
sp_events can be used to program different
database reads in the database program, depending on which tables and fields are used and filled. For
example, it is possible to use views or joins and collect the read records in internal tables and thereby process the internal tables at a later time and trigger the related
7.31 | 7.40 | 7.54
An imaginary logical database ZZF with the root node KNA1 is associated with the search help DEBI. The selection include DBZZFSEL contains the following lines:
SELECT-OPTIONS skunnr FOR kna1-kunnr.
PARAMETERS p_sp AS SEARCH PATTERN FOR NODE kna1.
The source text of the database program now contains further comment lines, indicating that the following tables and fields were created:
- Internal table
zzf_spin accordance with the following declaration:
kunnr LIKE kna1-kunnr,
END OF zzf_sp.
- Internal table
sp_fieldsin accordance with the following declaration:
DATA: BEGIN OF sp_fields OCCURS 10.
INCLUDE STRUCTURE rsspfields.
DATA: END OF sp_fields.
sp_fieldstells the program which fields these are. The component
suppliedis non-initial whenever the search help passes a value to the field in
- Internal table
sp_tablesin accordance with the following declaration:
DATA: BEGIN OF sp_tables OCCURS 10.
INCLUDE STRUCTURE rssptabs.
DATA: END OF sp_tables.
sp_tablestells the program which tables are covered by the search help. The component
suppliedis non-initial whenever the search help passes a value to the table in
- Character-like data object
sp_eventswith the length 200.
sp_tablesstands for a node in the structure of the logical database (for example, the first character stands for the root node). The content of the individual items has the following meaning for the node in question:
- "X2: Node is addressed in the application program using the statement
GETand the search help assigned values for the key fields to
- "R": Node is addressed in the application program using the statement
GET, but the search help did not assign values for the key fields to
- "M": Node is not addressed in the application program using the statement
GET, but the search help assigned values for the key fields to
- " ": Table is not addressed in the application program using the statement
GETand the search help did not assign values for the key fields to
If the user selects all vendors in the search help on the selection screen whose sort field starts with "ABC" and this applies to the customer numbers 17, 125, and 230 , the tables above are filled as follows:
put_zzf_sp (in comments) can now, for example, be modified and activated as follows to use the data records from the internal table
WHEN 'X' OR 'M'.
SELECT * FROM kna1 FOR ALL ENTRIES IN zzf_sp
WHERE kunnr = zzf_sp_kunnr.
get_events is used to check whether the application program contains
GET statement for KNA1 or whether the search help has assigned appropriate
values for key fields. If this is the case,
put_kna1_sp is called, which
SELECT loop across KNA1 to read the rows that match the key fields
zzf_sp. The statement
PUT kna1 is executed in the
SELECT loop. Another option would be as follows:
IF sp_everts(1) NE abap_false
skunnr-sign = 'I'.
skunnr-option = 'EQ'.
LOOP AT zzf_sp.
skunnt-low = zzf_sp-kunnr.
APPEND skunnr TO skunnr.
READ TABLE GET_EVENTS WITH KEY 'KNA1'.
IF sy-subrc = 0 AND get_events-kind IS NOT INITIAL.
This deletes the selection table
skunnr for KNA1 and fills it with values
zzf_sp. The table
get_events is used to check
whether the application program contains a
GET statement for KNA1. If this
is the case, the subroutine
put_kunnr is called. Here, the data from KNA1
is read as specified by the selection table
PUT kna1 is executed.