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 entries

Former Member
0 Kudos
116

Hi guru's

select * from vbak into table itab.

if itab[] is not initial.

so here if data is not fetched into itab then if i try to fetch data from vbap using for all entries.what happens does the data comes from vbap or not.

thanks in advacnce

7 REPLIES 7

Former Member
0 Kudos
89

no ,

regards

Peram

VXLozano
Active Contributor
0 Kudos
89

The system will return your program all the content of VBAP that accomplies with the conditions exposed in the WHERE clause.

Think about FOR ALL ENTRIES like a IN clause, exchanging a RANGE variable by an internal table. It makes things much more flexible, but a bit slower.

If your VBAK query has returned zero rows (sy-dbcnt = 0 or sy-subrc <> 0 or IS INITIAL), then the FOR ALL ENTRIES clause and all the conditions related in the WHERE are ignored, and the system will fetch you with ALL the rows in the table... never use it if you don't have rows in your initial internal table!

Former Member
0 Kudos
89

hi,

select * from vbak into table itab.

if itab[] is not initial.

select * from vbap for all entreis in itab into table itab where vbeln = itab-vbeln.

endif.

in this case if there are no entreis in itab then no records will be fetched.. becuase you are checking for itab is initial or not..

if you remove this condition if itab[] is not initial and itab does not contain any records then all the records from vbap are fetched..

Thanks

Mahesh

alejandro_bindi
Active Contributor
0 Kudos
89

If data is not fetched from VBAK into itab, and you try to select from VBAP using FOR ALL ENTRIES (removing the IF condition you coded), what happens is that you select ALL data from VBAP (WHERE clauses are not taken into account at all).

So you always have to make sure driver table (itab in your case) is not empty previously to use FOR ALL ENTRIES.

Regards

Please reward points if helpful.

Message was edited by:

Alejandro Bindi

Former Member
0 Kudos
89

select * from vbak into table it_vbak

up to 20 rows.

if not it_vbak[] is initial.

select VBELN

POSNR

MATNR

MATWA

PMATN from vbap

into table it_vbap

for all entries in it_vbak

where vbeln = it_vbak-vblen

if sy-subrc = 0.

sort it_vbap by vbeln.

endif.

endif.

using for all enteris we can get the data from multiple tables.

we can do using joins.but for all entires is best performance.

Former Member
0 Kudos
89

No,

VBAP is a database table and not an internal table, then how come you can use it with "FOR ALL ENTRIES" ??

Former Member
0 Kudos
89

thanks a lot its helpful