Application Development 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: 

for all enteries

Former Member
0 Kudos

what is the use of FOR ALL ENTERIES in a select statement

10 REPLIES 10

Former Member
0 Kudos

Hi Sekhar,

for ex: you have itab1 and itab2, if you need to fetch the data from dbtable into itab2 by comparing itab1 values you can use for all entries statement.

<b>Reward points for helpful answers</b>

Satish

Former Member
0 Kudos

Hi,

You can use it like this:


SELECT * FROM header INTO TABLE lt_headers WHERE ...

SELECT * FROM positions 
              INTO TABLE lt_positions 
              FOR ALL ENTRIES IN lt_headers
              WHERE positions-key EQ lt_headers-key.

The advantage is that you have only <b>one</b> SELECT statement for the positions table resulting in better performance than the ABAP "old style" programming of looping through the headers table and selecting the positions one-by-one.

Hope this helps (please reward me if it does).

Regards, Joerg

Former Member
0 Kudos

for all entries used to select your values from another internal table which matches the where condition criteria.

for ex:

select * from makt into table it_makt for all entries in it_mara

where matnr = it_mara-matnr.

Reward points if its helpful

Regards,

Vimal

Former Member
0 Kudos

Hi,

If you want to fetch data from a database table based on the data present in internal table,u can use for all enteries addition in the select statement.

Reward if useful.

Regards

Shibin

Former Member
0 Kudos

Hi

you have 5 entries in header table. For example consider you are having 5 sales orders in ITAB.

Now you want to select all the itams belong to those 5 sales order. you can loop at ITAB and for each sales order you can SELECT item data. But that is not efficient.

So we can use FOR ALL ENTRIES..

SELECT *

FROM VBAP

INTO table t_vbap

FOR ALL ENTRIES IN ITAB

WHERE vbeln EQ itab-vbeln.

it will fecth all the items belong to 5 sales orders.

Former Member
0 Kudos

u can feacth the data from internal tables and performance wise also it is good.u can join cluster and tranparent tables.

Former Member
0 Kudos

Hi,

We use FOR ALL ENTRIES in a SELECT statement when we want to select data from the second table for each and every record in the first table.

ex:

select vbeln

erdat

ernam

vdatu

angdt

bnddt

vsbed

kunnr

from vbak

into corresponding fields of table i_vbak

where vbeln in sorange.

select vbeln

posnr

matnr

arktx

kwmeng

vrkme

waerk

netpr

netwr

from vbap

into corresponding fields of table i_vbap

for all entries in i_vbak

where vbeln = i_vbak-vbeln.

Former Member
0 Kudos

Hello,

select * from <table> into itab for all entries in <stucture/internal table> where <condition>

this will select & display entries from <table> for only those entries present in <stucture/internal table>

Former Member
0 Kudos

Hi,

This is the answer to your question :-

SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result set. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records (in the current client).

Thanks & Regards

Jitendra