‎2008 Feb 04 3:58 AM
what is meant by for all entries in select statement.
why we use it.
why we use the internal table declaration in a programm.
‎2008 Feb 04 4:04 AM
lemme explain it with an e.g.
suppose that you have populated an internal table for header let EKKO
now when you will populate details from EKPO then it is abvious that all header will have some detail associated so we use " for all enteries " because it takes less time then select statement with where clause.
and your second question about internal table .... we use internal table because we want to avoid continuous read operation from database tables as they are more cost consuming and they might cause performance degradation when more than one user tries to access same table let EKKO then there is condition of deadlock
plz reward if useful
keep rockin
vivek
‎2008 Feb 04 4:07 AM
pls check
select SCHARG SXAUTO SMATNR SERFMG SUMLGO SBWART SMBLNR SZEILE "K~BUDAT
into corresponding fields of table atab
from mkpf as k
inner join mseg as s on smblnr = kmblnr and smjahr = kmjahr
where ( k~budat in date
and s~matnr in mno
and S~charg in jobno
and lgort EQ 'GFIS'
and bwart in ('311','312')
).
sort atab ASCENDING by charg.
select bwart charg erfmg matnr aufnr matnr mblnr zeile
into CORRESPONDING FIELDS OF TABLE prodatab
from mseg
for all ENTRIES IN btab
where ( charg = btab-charg or charg = btab-rpcharg )
"and matnr = btab-matnr
and ( lgort = 'PF05' or lgort = 'PF06' )
and ( bwart = '101' or bwart = '102' ).
The effect of FOR ALL ENTRIES need to be observed first by running a test program and analyzng SQL trace. Certain options set by BASIS can cause FOR ALL ENTRIES to execute as an 'OR' condition. This means if the table being used FOR ALL ENTRIES has 3 records, SQL Trace will show 3 SQL's getting executed. In such a case using FOR ALL ENTRIES is useless. However of the SQL Trace shows 1 SQL statement it's beneficial since in this case FOR ALL ENTRIES is actually getting executed as an IN List.
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
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.
REWARD IF USEFUL,
GAURAV J.
‎2008 Feb 04 4:10 AM
Hi Jayant,
The for all entries statement in select is mostly used for Internal tables.
This condition checks for all the entries in the internal table for the condition mentioned in the select statement.
Also usage of database tables will leads to less efficiency as the database hits will be more. So it is always advisabale to use internal table with the statement for all entries.
Pls reward if useful.
Regards,
Sirisha.
‎2008 Feb 04 4:14 AM
Hai.
you can type for all entries of in abap editor and press f1 you can get all information about it.
regards.
sowjanya.b.