06-27-2008 11:31 AM
hi experts,
i am using for all entries in a select query for fetching the database records from entries in internal table, but i a face a problem that i could not get all the records from database which satisfy the where condition . can any one tell me what precautions should i take for fetching all records form database for entries in a internal table
06-27-2008 11:34 AM
You need to extract more fields which will result in the records being extracted unique.
06-27-2008 11:35 AM
if the internal table for which u r selecting for all entries is itab,
then before the select query use..
if not itab[] is initial.
write select statement
endif.
if itab[] is initial, performance issue will come.....
Reward points if useful...
06-27-2008 11:37 AM
Hi Kiran,
I donot see this as a problem.
FOR ALL ENTRIES IN itab is similar to writing Select ... WHERE ... IN clause.
So there can be the following problems.
1. When you write FOR ALL ENTRIES IN itab in the WHERE condition you should have some key of table mapped with some key of itab.
2. There are no entries matching the records.
Regards,
Saurabh
06-27-2008 11:38 AM
Kiran,
Effect
If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.
The internal table itab must have a structured line type and the component comp must be compatible with the column col.
The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.
The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.
In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.
The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL ENTRIES, they are not passed to the database system but are applied instead to the resulting set once all selected rows on the application server have been imported.
*With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.*
Addition FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement.
Amit
06-27-2008 11:41 AM
hi check this ...
after using the for all entries ..
you need to use the read statement..
check this program..
tables:mara,marc.
data:begin of itab occurs 0,
matnr like mara-matnr,
end of itab.
data:begin of itab1 occurs 0,
matnr like marc-matnr,
werks like marc-werks,
end of itab1.
select matnr
from mara
into corresponding fields of table itab.
if itab is initial.
select matnr
werks
from marc
into table itab1
for all entries in itab
where matnr = itab-matnr.
loop at itab1.
read table itab with key matnr = itab-matnr.
write:/ itab1-matnr,itab1-werks.
endloop.
endif.