Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Join + For all entries

Former Member
0 Likes
945

When we use FOR ALL ENTRIES in a select statement having joins, does control goes to Database everytime

for each entry in internal table?

When we use FOR ALL ENTRIES in a select statement having joins, does control goes to Database everytime

for each entry in internal table?

6 REPLIES 6
Read only

Former Member
0 Likes
902

Hi,

We use the for all entries to fetch the data based on already fetched data which might be present in the another internal table ...and for those records only we need to find another records...it will read DB table ..

To avoid this just fetch all required data and then based on condition use READ from itab.

Read only

0 Likes
902

NO .. it hits the db only once.. if there is a performance hit, it might be due to your join.. is it a complex join?

Anyway,this is what SAP's docu says.."SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table "

~Suresh

Read only

Former Member
0 Likes
902

Hi,

Inner join selects a record and checks for

matches with each entry in internal table by

hitting database.

Check if internal is not empty to avoid

performance problem and alao delete

sort internal table by deleting duplicate keys

Regards,

Amole

Read only

Former Member
0 Likes
902

hi

good

Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below

Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.

If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.

If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.

Not Recommended

Loop at int_cntry.

Select single * from zfligh into int_fligh

where cntry = int_cntry-cntry.

Append int_fligh.

Endloop.

Recommended

Select * from zfligh appending table int_fligh

For all entries in int_cntry

Where cntry = int_cntry-cntry.

thanks

mrutyun

Read only

Former Member
0 Likes
902

Yes, internally the control goes to DB to fetch the records for each entry in the internal table. But please note for ABAP code it is executed as a single statement you would not see that looping in debug etc.

Read only

Former Member
0 Likes
902

Hi,

There will be only one hit on DB.

Regards

vijay