Mentor SAP
The SELECT... FOR ALL ENTRIES IN <itab> is mapped in a SELECT statement with an external OR link (depending on optimizer and profile parameters). The system only selects those table entries that meet the logical condition (WHERE carrid = gt_spfli-carrid), replacing the placeholders (gt_spfli-carrid) with values from each entry in the gt_spfli internal table. Note that gt_spfli-carrid is a placeholder, and not a component of the internal table.

 

DELETE ADJACENT DUPLICATES prevents duplication of records in the internal table (and therefore, multiple reads of the same data). The internal table, in principle, can be as large as you want.

 

It is recommended that you use the FOR ALL ENTRIES addition when the first set of data is not being read from the database and is already available in the program, for example, if the user has input the data. Otherwise, a join is recommended.

 

 

Nested SELECT Statements

Nested SELECT statements are another method to read related tables. Avoid this technique and use it only as a last resort when no other data retrieval method is possible.

 

The major disadvantage of nested SELECT statements is that the inner SELECT is executed for each record that is retrieved by the outer SELECT statements. Under these circumstances, good performance is only possible if you ensure that the table with the smallest number of expected records is outermost in the nesting structure.