‎2006 Oct 09 2:39 PM
what precaution need to be taken while using the query
select.....forallentries.......
‎2006 Oct 09 2:44 PM
Hi,
Kindly check the <b>syntax</b>:
... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
The internal table itab must have a <b>structured line type</b> and the component comp must be
compatible with the column col.
The logical expression sql_cond of the WHERE condition can comprise various
<b>logical expressions</b> 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 SELECT statement 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 <b>is empty</b>, the whole WHERE statement is ignored and
all lines in the database are put in the resulting set.
hope this helps!
best regards,
Thangesh
‎2006 Oct 09 2:41 PM
Check if your internal table is not initial.
if not itab[] is initial.
select *
from <table>
into table it_final
for all entries in itab
where....
endif.
‎2006 Oct 09 2:44 PM
Hi,
Kindly check the <b>syntax</b>:
... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...
The internal table itab must have a <b>structured line type</b> and the component comp must be
compatible with the column col.
The logical expression sql_cond of the WHERE condition can comprise various
<b>logical expressions</b> 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 SELECT statement 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 <b>is empty</b>, the whole WHERE statement is ignored and
all lines in the database are put in the resulting set.
hope this helps!
best regards,
Thangesh
‎2006 Oct 09 2:48 PM
Hi,
case 1.
Select * from a
into it_a
where <>.
if sy-subrc = 0.
Select * from b
into it_b
for all entries in it_a
where <>.
endif.
case2.
Select * from a
into it_a
where <>.
if not it_a[] is initial.
Select * from b
into it_b
for all entries in it_a
where <>.
endif.
if you miss those checks then you will endup with full database fetch.
Regards
vijay