‎2007 Mar 21 9:47 AM
can anybody plz explain me
what is this FOR ALL ENTRIES ?
why we should go for it ?
‎2007 Mar 21 9:50 AM
‎2007 Mar 21 9:50 AM
If you have some data in an internal table.
You need to get some additional data from a data base table for each record of the internal table. then you use for all entries.
select * from <table>
into table itab_final
for all entries in itab
where field = itab-field.
Regards,
Ravi
‎2007 Mar 21 9:51 AM
Hi,
First fetch the data from a db table into an Internal table ITAB,
Using the data of this ITAB, if you wants to fetch the data from different tables then we use this command;
If not ITAB[] is initial.
select F1 F2 F3 from DB Table into ITAB1
for all entries in ITAB
where f1 = ITAB-f1.
rewrad if useful
regards,
Anji
‎2007 Mar 21 9:51 AM
hai
in short very useful
To avoid nested select statements we use SELECT FOR ALL ENTRIES statement. If there r more than 10000 records SELECT FOR ALL ENTRIES is used. Performance wise SELECT FOR ALL ENTRIES is better to use.
**Please reward suitable points***
With Regards
Navin Khedikar
‎2007 Mar 21 9:52 AM
Hi,
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
1)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.
2)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.
3)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.
regards,
bharat.
‎2007 Mar 21 9:52 AM
Hi,
U can join 2 tables by using joins but the performance goes down. This can be overcomed by for all entries.
Advantages:-
1.The itab loop is avoided i.e. it helps in performance.
2. If you do not put all the key fields in the Select clause, duplicate entries if any will not be retrieved.
LOOP AT itab.
...
...
SELECT ... FROM ... WHERE ... = itab-anything.
..
..
ENDLOOP.
Here's an example:
SELECT matnr mtart
FROM mara
INTO TABLE t_mara
WHERE matnr IN s_matnr.
IF NOT t_mara[] IS INITIAL.
SELECT matnr maktx
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_mara
WHERE matnr EQ t_mara-matnr.
ENDIF.
Regards,
Priyanka.
‎2007 Mar 21 9:53 AM
Hi,
Check this info.
we are using select for all entries to avoid inner joins..
suppose
select vbeln from vbak into corresponding fields of table itab.
if not itab[] is initial.
select <fields> from vbap into corresponding fields of table itab1 for all entries in itab where vbeln = itab-vbeln.
endif.
it will fetch the data by comparing vbeln of itab and vbap but one thing you have to check itab is initial or not if it is not initial(not contain any data) then you should not use for all entries it will fetch all the values from vbap.
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Select using JOINS
The plus
Very large amount of data
Similar to Nested selects - when the accesses are planned by the programmer
In some cases the fastest
Not so memory critical
The minus
Very difficult to program/understand
Mixing processing and reading of data not possible
For further reference regarding optimization you can look into this link....
Hope this resolves your query.
Reward all the helpful answers.
Regards
‎2007 Mar 21 10:37 AM
Hi,
For better performance we should use FOR ALL ENTRIES instead of Using SELECT statement inside Loop End Loop.
If you have to select data from more than two tables in that case frist try to join two tables get all the necessary data in one internal table then if the content of that internal table is not null, considering that internal table as a driver table you can select all the necessary data from other tables using FOR ALL ENTRIES which will give better performance.
If sounds good pl reward.
Cheers.