05-14-2008 8:48 AM
what is the purpose of keyword for all entries and the various issues of it.
05-14-2008 8:51 AM
Hi
When using FOR ALL ENTRIES the number of matching records is restricted to the number of records in the internal table. If the number of records in the database tables is too large then join would cause overheads in performance. Additionally a JOIN bypasses the table buffering.
So for all entries is used for filtering out the data from the two tables based on the entries in them.
check this link
Reward Me Points
BY
Pari
05-14-2008 8:51 AM
Hi
When using FOR ALL ENTRIES the number of matching records is restricted to the number of records in the internal table. If the number of records in the database tables is too large then join would cause overheads in performance. Additionally a JOIN bypasses the table buffering.
So for all entries is used for filtering out the data from the two tables based on the entries in them.
check this link
Reward Me Points
BY
Pari
05-14-2008 8:59 AM
lets say there is an internal table itab1 which has some data.
now based on one of the fields of itab1, you want to select some data into itab 2 from a database tables...
select * from <dbtable> into table itab2 for all entries in itab1 where f1 = itab1-f1.
so this statement matches the field f1 of the database tables with the values of the same field f1 in the itab1 internal table. all the matching rows are returned in table itab2.
the thing to note here is that suppose if the internal table itab1 is blank (has no records) then the where clause in the query will not be executed and all the data will be retrieved into the table. so while using FOR ALL ENTRIES, make sure that you do a check on the table not being blank
do it this way...
if itab1[] is not initial.
select * from <dbtable> into table itab2 for all entries in itab1 where f1 = itab1-f1.
endif.
05-14-2008 8:59 AM
hi
We use for all entries, when we need to fetch data from two tables. The search key is common.
Like you may need to fetch data from BKPF and BSEG. Two tables. You can fetch BELNR's from BKPF on certain conditions and then for only those BELNR's you can fetch entries from BSEG.
This is better and faster than joins.
The syntax is as follows:
Select Belnr bukrs ..
from bkpf into corresponding fields of table it_bkpf
where budat in s_budat. <Suppose>
then check whether values are fetched or not.
if not it_bkpf[] is initial.
select belnr dmbtr <etc>
from bseg
into corresponding fields of table it_bseg
for all entries in it_bkpf
where belnr = it_bkpf-belnr.
endif.
Use of FOR ALL Entries
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.
Thats it with for all entries.
Expected Reward points
prasanth
05-14-2008 9:00 AM
Hi Sandeep,
for all entries is the key word used insted of wrting a select statement in loop and endloop.
for example see
in one intrenal table u have some fields based on that field values u want to retrive the data then u will do like this ..
loop itab.
select * from table into itab1 where field1 eq itab-field1.
append itab1.
endselect.
endloop.
instead of the u can write
select * from table into itab1 for all entries in itab where field1 = itab-field1.
but ...
in u r quer either in select clause or where clause u should manintin the entire key this is the mandatory or else it will not throw any syntactical error but data loss will be there it will be blunder hope i am making sense ..
plzz reward if useful..
Thanks and regards
Sunil Kumar Mutyala