You are on page 1of 2

n Use SELECT FOR ALL ENTRIES in order to divide SELECT statements into loops.

This variant enables you to create a JOIN between an internal table and a database table. In
the example above, only the records from table KKNA1 are read that have customer
numbers in the internal table g_itab_vvbak.
n In connection with SELECT ... FOR ALL ENTRIES the following problems occur:
Ÿ You cannot have an empty internal driver table. If the driver table is empty, selection is
not limited. In particular, WHERE clause conditions are not evaluated if they do not
refer to the internal driver table.
Ÿ Duplicate table entries should be deleted from the internal table before executing the
SELECT... FOR ALL ENTRIES. If they are not deleted, identical data is read
unnecessarily from the database.
Ÿ The parameter rsdb/max_blocking_factor must be implemented according to SAP's
database-specific recommendations.
SELECT FOR ALL ENTRIES (2)

Object Oper Rec


VVBAK REOPEN 0 SELECT
"KUNNR" , "ADRNR"
VVBAK FETCH 100000 FROM
KKNA1 REOPEN 0 "KKNA1"
KKNA1 FETCH 149 WHERE
KKNA1 REOPEN 0 "MANDT" = :A0 AND "KUNNR" = :A1
OR "MANDT" = :A2 AND "KUNNR" = :A3
KKNA1 FETCH 149 OR "MANDT" = :A4 AND "KUNNR" = :A5
KKNA1 REOPEN 0 OR "MANDT" = :A6 AND "KUNNR" = :A7
KKNA1 FETCH 149 ....
... ... ...
rsdb/max_blocking_factor
gives the maximum
number of statements
SELECT STATEMENT (Estimated Costs = .... )
concatenated with OR
CONCATENATION

TABLE ACESS BY INDEX ROWID KKNA1

INDEX UNIQUE SCAN KKNA1~0

TABLE ACESS BY INDEX ROWID KKNA1

INDEX UNIQUE SCAN KKNA1~0


© SAP AG 1999

n The SELECT ... SELECT FOR ALL ENTRIES addition ensures that SQL
statements are divided into several SELECT statements by the database interface. The
individual SELECT statements are processed on the database and the results are buffered
in the database interface. The database interface eliminates duplicate data records from the
results set and transfers the results set to the ABAP program.
n Each SELECT statement processed on the database is executed as a concatenation of
individual accesses (for example, index range scans or index unique scans). Concatenation
is performed over the entries in the internal driver table. Since the SELECT ... FOR
ALL ENTRIES may be very complex, it should not be combined with RANGES tables.
n The implementation of the WHERE clause for individual SELECT statements depends on
the database and is realized by the database interface.
n The profile parameter rsdb/max_blocking_factor controls the maximum number of
individual WHERE conditions that can be concatenated. SAP pre-configures this
parameter according to the database. For Oracle the setting is 15.