SAP LDB SEARCH HELP



Get Example source ABAP code based on a different SAP table
  



ABAP_LDB - Link with Search Helps
A logical database can be assigned 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 at runtime for the actual access to 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 allowed for every individual field.
The runtime framework is responsible for interpreting the user input on the selection screen and reading the value list from the database. These lines 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 put_node. Here, ldb is the name of the logical database. The value list in the internal table ldb_sp is used to enable this subroutine to read the actual data and raise the event GET for the root node using the statement PUT. It is often useful to call the subroutine put_node for the root node from put_ldb_sp. The subroutine then selects the data and raises the associated GET event using PUT. The structure of the internal table ldb_sp 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 internal tables get_events, sp_fields, and 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 later and raise the respective GET events.



Example ABAP Coding

An imaginary logical database ZZF with the root node KNA1 is linked 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_sp in accordance with the following declaration: DATA: BEGIN OF zzf_sp OCCURS 1000,
kunnr LIKE kna1-kunnr,
END OF zzf_sp. The search help selections of the user create a hit list in the filled output fields of the search help. This hit list is passed to the database program in the table zzf_sp.
Internal table sp_fields in accordance with the following declaration: DATA: BEGIN OF sp_fields OCCURS 10.