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

For All Entries

Former Member
0 Likes
1,155

Hey guys,

What does for all entries actually does?

Sample Code:

SELECT vbeln

posnr

matnr

kwmeng

kbmeng

vrkme

werks

FROM vbap

INTO TABLE i_vbap

FOR ALL ENTRIES IN i_vbak

WHERE vbeln EQ i_vbak-vbeln

AND abgru EQ space.

Thanks!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,133

Hi,

see if i_vbap has 4 entries with

1) vbeln = 10

2) vbeln = 20

3) vbeln = 30

4) vbeln = 40

now see ur query it behaves like dis.......

SELECT vbeln

posnr

matnr

kwmeng

kbmeng

vrkme

werks

FROM vbap

INTO TABLE i_vbap

WHERE ( vbeln EQ 10 or vbeln EQ 20 or vbeln EQ 30 or vbeln EQ 40 )

AND abgru EQ space.

Cheers,

jose.

8 REPLIES 8
Read only

Former Member
0 Likes
1,133

HI,

the select shows you all entries in vbap where the vbeln is also in the internal table i_vbak.

so ... you need to fill the intern table first.

regards

Nicole

Read only

former_member404244
Active Contributor
0 Likes
1,133

hi,

it will retrieve the data that is thre in table i_vbak..that means if the internal table has 100 records then it will retrieve 100 records data from table VBAP...basing on vbeln

it removes the duplicate entries..

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,133

Hi Mark ,

In this statement data is selected from table VBAP based on the entreis in the internal table i_vbak . i.e if the table contains

vbeln equal to the entry in internal table and abgru eq space then the resord is selected.

Regards

Arun

Read only

Former Member
0 Likes
1,133

FOR ALL ENTRIES works like INNER JOIN

Performance wise it is better tahn INNER JOIN

If u use FOR ALL ENTRIES, 1st we have to populate the 1st ITAB.

If the 1st ITAB is not empty the we have to populate the 2nd ITAB based on the entries of 1st ITAB.

SELECT vbeln posnr matnr kwmeng kbmeng vrkme werks

FROM vbap

INTO TABLE i_vbap

FOR ALL ENTRIES IN i_vbak

WHERE vbeln EQ i_vbak-vbeln

AND abgru EQ space.

In ur code, it fetches the record s from VBAP, which are alredy in i_vbak. (ie for all entries in i_vbak, we get the records)

so, 1st u have to populate i_vbak from the databse table VBAK

Reward if useful

Narendra

Read only

Former Member
0 Likes
1,134

Hi,

see if i_vbap has 4 entries with

1) vbeln = 10

2) vbeln = 20

3) vbeln = 30

4) vbeln = 40

now see ur query it behaves like dis.......

SELECT vbeln

posnr

matnr

kwmeng

kbmeng

vrkme

werks

FROM vbap

INTO TABLE i_vbap

WHERE ( vbeln EQ 10 or vbeln EQ 20 or vbeln EQ 30 or vbeln EQ 40 )

AND abgru EQ space.

Cheers,

jose.

Read only

Former Member
0 Likes
1,133

Instead of writing a join on two tables.. say in your case

vbap and vbak(I think U got the information into i_vbak

from table vbak) .. U can write For all entries ..

But .. before writing check if i_vbak[] is initial ..

If not i_vbak[] is initial.

write the select for all entries ...

endif.

It gets the data from vbap for all the vbeln's where

vbap-vbeln = vbeln's in vbak

Read only

Former Member
0 Likes
1,133

Hi,

There are 3 prerequisites for using 'for all entries'.They are:

1.Adjacent duplicates has to be deleted,

2.The first table has to be initial(in your case i_vbak)

3.Correct relationship betwn 2 tables has to be maintained.

For ur select query,

it selects the specified fields from vbap and populate into i_vbap by checking the condition i_vbak-vbeln = i_vbap-vbeln and AND abgru = space.

rewards if useful..

regards,

kavitha

Read only

Former Member
0 Likes
1,133

HI Mark

FOR ALL ENTRIES

should be used wherevr possible for the Performance Reasons .

Always Check the while using For All Entries

The Internal should not be be Initial otherwise it will select all the records irrespctive of the where condition .

In your Condition .

SELECT vbeln

posnr

matnr

kwmeng

kbmeng

vrkme

werks

FROM vbap

INTO TABLE i_vbap

FOR ALL ENTRIES IN i_vbak

WHERE vbeln EQ i_vbak-vbeln

AND abgru EQ space.

Only Those Records From VBAP are selected , where

VBELN = i_vbak-vbeln

.

For eg if I_VBAK has 100 records

but in VBAP abgru is space only for VBELN 1 to 10 .

THEN I_VBAP will have only 10 records with VBELN from 1 to 10 .

Hope its clear .

Thanks

Praveen