Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

query

Former Member
0 Likes
403

what precaution need to be taken while using the query

select.....forallentries.......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
382

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

3 REPLIES 3
Read only

Former Member
0 Likes
382

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.

Read only

Former Member
0 Likes
383

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

Read only

Former Member
0 Likes
382

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