05-28-2008 11:02 AM
hell all
i want to fetch the data from two tables, one is from internal table and another one is data base table. what syntax i have to use either FOR ALL ENTRIES or INNER JOIN?
05-28-2008 11:05 AM
Select *
from (Standard Table)
into table ITAB
where (conditions)
if not ITAB is initial.
Select *
from (Standard table 2)
into table ITAB2
FOR ALL ENTRIES IN ITAB
where (Conditions eq itab-fields atleast one).
endif.
Regards
Kannaiah
05-28-2008 11:07 AM
hi,
you can not fetch data from internal table because its already there for temporary.
select queries are applied for data base fetch.
you can fetch data from database table.
you can make use of your internal table data.
i don know your requirement..
05-28-2008 11:09 AM
Hi.
Use All Entries.
use this code
Select * from EKKO table into it_ekko.
IF it_EKKO[] IS NOT INITIAL.
SELECT * FROM EKPO
INTO TABLE it_EKPO
FOR ALL ENTRIES IN it_EKKO
WHERE vbeln = it_EKKO-vbeln.
endif.
Regards,
jay
05-28-2008 11:11 AM
Hi,
You have to use for all entries only. Just have a glance with the following code. It will give you some sense.
data : itab like mara occurs 0 with header line,
itab1 like mseg occurs 0 with header line.
start-of-selection.
select * from mara into table itab where mtart = 'FERT'.
select * from mseg into corresponding fields of table itab1
for all entries in itab where matnr = itab-matnr
and bwart = '131'.
Regards,
Sankar.
05-28-2008 11:14 AM
hi
'FOR ALL ENTRIES' is used to improve ur system performance
its good practice to write code which use less db access.
'FOR ALL ENTRIES' is used with internal tables.
1) fetch data for single itab and use it with 'FOR ALL ENTRIES'
and populate the other tables.
sample code for the same:
select vbeln
posnr
matwa
matkl
from vbap into table vbap_it where vbeln in salesdoc.
select vbeln
erdat
ernam
from vbak into table vbap_it1 for all entries in vbap_it
where vbeln = vbap_it-vbeln.
use inner in ur prog. and populate itab1
then use for all entries in next select query
reward points if helpful
regards
mano
05-28-2008 11:15 AM
hi
Use FOR ALL ENTRIES.
see the sample code
select * into table tvbrk from vbrk
where fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM' , 'ZVED',
'S1')
and erdat in so_erdat
and kunag in s_kunag.
erdat in so_erdat
and fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM').
if not tvbrk is initial.
select * into table t_zregion from zregion
for all entries in tvbrk
where country = tvbrk-land1
and region = s_regio.
endif.
thanks
sitaram
05-28-2008 11:22 AM
Hi,
Use 'All Entries'
code :
Select * from TableA(Database Table) into itab.
IF itab[] IS NOT INITIAL.
SELECT * FROM TableA
INTO TABLE itab
FOR ALL ENTRIES IN itab
WHERE Field1(Database Table field) = itab-Field1.
endif.
Regards,
Biswanath
05-28-2008 11:30 AM
Hi Swamy,
Its not advisable to use INNER JOIN for than 3 tables.
Its better to use FOR ALL ENTRIES instead.