‎2007 Oct 29 1:10 AM
Hello
This is lalitha
in the select statement the syntax
(if it_vbak[] is not initial.
select * from vbap into table it_vbap
for all entries in it_vbak where kunnr = it_vbak-kunnr .)
I want to know the meaning of initial ie what values of vbak is it selecting & for all entries in it_vbak .
‎2007 Oct 29 1:46 AM
(a) "if not it_vbak[] is initial." means that the logic will only be executed if the internal table it_vbak has contents i.e. at least one row.
(b) The "for all entries in" will generate a select statement along the lines of "where kunnr = X or kunnr = Y or kunnr = Z" where X,Y, and Z are taken from the rows in it_vbak.
(c) the reason for (a) is that if you specifiy an empty table in (b), you will end up selecting all the data from vbap - i.e. a "for all entries in" with an empty internal table specified will return everything, not nothing. As the online help says "Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set."
Jonathan
‎2007 Oct 29 1:51 AM
Hi Lalitha,
if it_vbak[] is not initial.
<b>- If there are values in the table it_vbak then only you will call the below select statement. The reason being if there are no values in internal table and you use thte same in FOR ALL ENTRIES then all the records will be selected from VBAP</b>
select * from vbap into table it_vbap
for all entries in it_vbak where kunnr = it_vbak-kunnr
Regards,
Atish