‎2008 Jan 11 7:21 AM
Hi
Prob: I want to insert a record into an Internal Table.
But the values of the fields of Internal Table are scattered in different tables.
The situation is like that I cannot use a join condition or for all entries here.
Query: Advise me how can I retrieve values and enter them to Internal Table fields in compliance with SELECT statements for different tables.
Thx
‎2008 Jan 11 7:25 AM
hi,
use for all entries
For ex:-
SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart
dmbtr mwart hwbas aufnr projk shkzg kokrs
FROM bseg
INTO TABLE it_bseg
FOR ALL ENTRIES IN it_bkpf
WHERE bukrs EQ it_bkpf-bukrs AND
belnr EQ it_bkpf-belnr AND
gjahr EQ it_bkpf-gjahr.
Reward if useful
Regards
‎2008 Jan 11 7:29 AM
‎2008 Jan 11 7:31 AM
Hi, Santo.
I think we can select values from different tables into a work area, may be use many 'select' statements, then append or insert this work area to the internal table.
Regards,
feng.
‎2008 Jan 11 7:32 AM
use
loop at internaltablename into wa.
modify finalinternaltable from wa.
endloop.
‎2008 Jan 11 7:32 AM
use data extract to get the fields....
each row will fetch the fields in different tables ...
‎2008 Jan 11 7:33 AM
Hi,
Loop the internal table and fetch data from the tables for each record and modify the table.
Loop at itab.
select f1 into itab-f1
from Zxxx
where f2 = itab-f2.
modify itab transporting f1.
endloop.
Hope this helps you.
‎2008 Jan 11 7:33 AM
‎2008 Jan 11 7:36 AM
hi,
you can select fields from one table into an internal table and then can use
FOR ALL ENTRIES IN to fetch the data from another database table based on the field in the internal table.
for ex....
select A B C from db_table
into it_tab.
select X Y Z from db_table2
into it_tab2
for all entries in it_tab
where x = it_tab-A.
IF u have to fetch the fields from db_table based on the fields from more then one table then u can use range and fetch based on both range and for all entries in.
for ex.
select X Y Z from db_table2
into it_tab2
for all entries in it_tab
where x = it_tab-A and
y in r_range.
regards
vijay
reward points if helpfull
‎2008 Jan 11 7:44 AM
Hi Santo,
You can try it...
SELECT f1 f2 f3 f4 f5
FROM main1 INTO TABLE it_main1
WHERE f1 IN <S1>.
SORT it_main1 BY f1.
IF it_main1[] IS NOT INITIAL.
SELECT a1 a2 a3 a4 a5
FROM table1 INTO TABLE it_table1
FOR ALL ENTRIES IN it_main1
WHERE a1 = it_main1-f1.
SELECT ******
******
******
SELECT******
*****
******
ENDIF.
LOOP AT it_table1 INTO wa_table1.
READ TABLE it_main1 INTO wa_main1 WITH KEY f1 = wa_table1-a1.
wa_final-x1 = wa_table1-a1.
wa_final-x2 = wa_table1-a2.
wa_final-x3 = wa_main1-f2.
wa_final-x4 = wa_main1-f3.
wa_final-x5 = wa_main1-f5.
wa_final-x6 = wa_table2-p1.
wa_final-x7 = wa_table2-p6.
.
.
.
APPEND wa_final TO it_final.
ENDLOOP.
Regards,
Sayak... ..."reward if it is helpful"
‎2008 Jan 11 7:53 AM