DB Lookup Expression 
The DB Lookup expression performs a database lookup from within BRFplus. It is used to access the records stored in a data dictionary (DDIC) table or to retrieve information about a table. The expression provides the following modes:
Data Retrieval Mode
In this mode, the data is retrieved from a database table. The expression performs a simple selection operation in the specified table. The selection is defined by the following settings:
Selection Flag
Specifies whether a multiple select or a single select should be performed.
Note
If you choose All Entries for the selection, the result data object assigned to the DB Lookup expression must be of table type.
Table Name
Specifies the database table from which data is read. You can access any table available in the data dictionary of the backend system.
Field Conditions
Specifies the conditions applied to the different table fields for refining the search result. Based on the field conditions, the where-clause of the performed selection is built.
The value that is actually selected from the table depends on the result data object type:
If the result data object is an element with a name corresponding to the one in the table fields, the expression only selects that one value.
If the result data object is a structure, then the database fields corresponding to the structure fields are read.
If the result data object is a table, then the fields corresponding to the table fields are read. Multiple entries can be read.
Aggregation Mode
In this mode, the result of an aggregation function applied to a database table is returned. The following aggregation functions are supported:
Maximum
Minimum
Sum
Average
Count
The aggregation functions can be applied on distinct fields or on entire table records (all fields in a row). The following example illustrates the effects of changing this setting:
Example
You create a DB Lookup expression that reads from DDIC table T100 which is used for storing message short texts in an SAP system. The expression shall return the number of records (aggregation function Count) with German short texts (SPRSL = DE). In a given system, the expression may yield the following results, depending on the distinction setting:
Setting |
Result |
Comment |
|---|---|---|
Select Count of Records From T100 With SPRSL = DE |
110650 |
Total of table rows with the language field (SPRSL) set to DE |
Select Count of ARBGB From T100 With SPRSL = DE |
1615 |
Total of message classes (ARBGB) with at least one message in language DE |
Select Count of SPRSL From T100 With SPRSL = DE |
1 |
Total of unique table rows with the SPRSL field set to DE. Though there are more than 100000 rows in the table that satisfy the condition, the distinct selection for the SPRSL field lets the search stop after the first match because the second match would already yield a duplicate. |
Note
All aggregation functions (with the exception of the Count function) can only be applied to fields that hold numeric data. Otherwise, the system displays an error message at runtime.
Existence Check Mode
In this mode, the result data object yields either true or false depending on whether a line exists in the DDIC table that satisfies the WHERE condition.