‎2007 Mar 21 2:00 PM
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
‎2007 Mar 21 2:09 PM
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
‎2007 Mar 21 2:06 PM
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
‎2007 Mar 21 2:06 PM
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.
‎2007 Mar 21 2:09 PM
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
‎2007 Mar 21 2:09 PM
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!
‎2007 Mar 21 2:11 PM
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.
‎2007 Mar 21 2:11 PM
what is the benefit of checking if the itab is initial when using for all entries ?
‎2007 Mar 21 2:13 PM
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
‎2007 Mar 21 2:13 PM
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.
‎2007 Mar 21 2:13 PM
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.
‎2007 Mar 21 2:14 PM
It is a prerequisite to check if itab is not initial when using FOR ALL ENTRIES..
Otherwise there is no use in using that