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

syntax issue

Former Member
0 Likes
1,030
select tvzbt~zterm tvzbt~vtext vbkd~vbeln
from tvzbt inner join vbkd on tvzbt~zterm = vbkd~zterm
into table itab8
for all entries in itab4
where tvzbt~spras = sy-langu 
and vbkd~vbeln = itab4-vbeln.

This is displaying all values of vbeln zterm and vtext in tvzbt

I want select only those vbeln zterm and vtext in tvzbt where tvzbt-zterm = vbkd-zterm and spras shud be en

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
993

Hi Megan,

Its always good practise to check whether internal table is initial or not before using FOR ALL ENTRIES option.

If internal table is empty, then it will consider all the entries of database table.

<b>IF ITAB4[] IS NOT INITIAL.</b>

select tvzbtzterm tvzbtvtext vbkd~vbeln

from tvzbt inner join vbkd on tvzbtzterm = vbkdzterm

into table itab8

for all entries in itab4

where tvzbt~spras = sy-langu

and vbkd~vbeln = itab4-vbeln.

<b>ENDIF.</b>

Thanks,

Vinay

10 REPLIES 10
Read only

Former Member
0 Likes
993

Hi,

Try this,

select tvzbtzterm tvzbtvtext vbkd~vbeln

from VBKD inner join TVZBT on vbkdzterm = tvzbtzterm

into table itab8

for all entries in itab4

where vbkd~vbeln = itab4-vbeln

and tvzbt~spras = sy-langu.

Thanks,

Rashmi.

Message was edited by:

Rashmi Joshi

Read only

ferry_lianto
Active Contributor
0 Likes
993

Hi,

Please try this if your logon language is not 'EN' (English).


select tvzbt~zterm tvzbt~vtext vbkd~vbeln
from tvzbt inner join vbkd on tvzbt~zterm = vbkd~zterm
into table itab8
for all entries in itab4
where tvzbt~spras = 'EN' 
and vbkd~vbeln = itab4-vbeln.

Read only

Former Member
0 Likes
994

Hi Megan,

Its always good practise to check whether internal table is initial or not before using FOR ALL ENTRIES option.

If internal table is empty, then it will consider all the entries of database table.

<b>IF ITAB4[] IS NOT INITIAL.</b>

select tvzbtzterm tvzbtvtext vbkd~vbeln

from tvzbt inner join vbkd on tvzbtzterm = vbkdzterm

into table itab8

for all entries in itab4

where tvzbt~spras = sy-langu

and vbkd~vbeln = itab4-vbeln.

<b>ENDIF.</b>

Thanks,

Vinay

Read only

Former Member
0 Likes
993

Please check itab4 has some values in it.

If it doesnt have any value then the select statement will select all the records from the tables you joined.

Put your select statement between the following code.

If itab4 is not initial.

<your select query>

Endif.

Hope that helps!

Read only

Former Member
0 Likes
993
delete adjacent duplicates from itab4 comparing vbeln.

if not itab[] is initial.

select tvzbt~zterm tvzbt~vtext vbkd~vbeln
from tvzbt inner join vbkd on tvzbt~zterm = vbkd~zterm
into table itab8
for all entries in itab4
where vbkd~vbeln = itab4-vbeln and
tvzbt~spras = sy-langu.

endif.
Read only

Former Member
0 Likes
993

what is the benefit of checking if the itab is initial when using for all entries ?

Read only

0 Likes
993

Hi Megan,

If you didnt check then it will consider all entries of the database entries into consideration.

So, it is always good practice to check whether internal table is initial or not before using FOR ALL ENTRIES option.

Thanks,

Vinay

Read only

0 Likes
993

Megan,

Like I said.....If itab4 doesnt has any records in it, your select query will fetch all the records.

Before 'for all entries' is used, One has to check if the internal table has some records in it.

Read only

0 Likes
993

FOR ALL ENTRIES IN itab will get all the database table records if the <itab> is empty. That is reason why you should check if the table has entries or not.

Read only

0 Likes
993

It is a prerequisite to check if itab is not initial when using FOR ALL ENTRIES..

Otherwise there is no use in using that