2006 Mar 02 4:58 AM
hi all,
i am havin an internal table with some data.i want to populate another internal table based on the data present in the first internal table.Can u plz tell me how to do it?
Thanks ina advance.
Anu
hi all,
i am havin an internal table with some data.i want to populate another internal table based on the data present in the first internal table.Can u plz tell me how to do it?
Thanks ina advance.
Anu
2006 Mar 02 5:01 AM
APPEND LINES OF itab1 TO itab2.
If you want to use condition...
LOOP AT itab1 WHERE <cond>.
APPEND itab1 TO itab2.
ENDLOOP.
2006 Mar 02 5:02 AM
let itab1 be ur first internal table. now u want to populate some data into itab2 based on itab1.
1.one way is using for all enties
example:
check not itab1[] is initial.
select * from <dbtab> into itab2
for all entries in itab1 where field1 = itab1-field1.
2.
if u want to move the contents of itab1 to itab2.
move-corresponding itab1 to itab2.
append itab2.
3.
another method is
loop at itab1.
select single <field1> <field2> from <dbtab> into itab2
where <field> = itab1-field.
endloop.
Message was edited by: Hymavathi Oruganti
2006 Mar 02 5:02 AM
hi ,
use..
APPEND LINES OF ITAB TO ITAB1. or
APPEND LINES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.itab1[] = itab[].
copy based on a condition..
LOOP AT ITAB WHERE <cond>.
move itab to itab1.
append itab.
endloop.regards
satesh
2006 Mar 02 5:02 AM
1st select some mandatory field in itab1.
loop at itab1 .
read table itab2 with key <field> = itab1-<field>.
modify itab1.
endloop.
2006 Mar 02 5:06 AM
hi
you can do that by using forallentries keyword
let me know if u want any other details
2006 Mar 02 5:28 AM
hi Anuradha,
Kindly close all your posts and reward all the helpful answers..
regards
satesh
2006 Mar 02 6:10 AM
u mean to say
select fields f1,f2,f3
into table itab2
from XXXX
for all entries in itab1 where key = itab1-key .
is this what u r looking for 'POPULATING' the second internal table .
____________________________________
if already second table is populated then i think all the possible hints are sufficient as given the members.
2006 Mar 02 6:20 AM
Hi Anuradha,
based on the first internal table
you can use for all entires if it data base query related.
select *
from <dbtab>
into itab2
for all entries in itab1
where field = itab-field.
or you want to populate the data from itab1 itslef.
"with out any condition..
loop at itab1 .
move-corresponding itab1 to itab2.
append itab2.
endloop.
with some condition..
loop at itab1 where <codition>.
move-corresponding itab1 to itab2.
append itab2.
endloop.
Regards
vijay
2006 Mar 02 6:24 AM
Hi Anuradha,
Assume ITAB1 and ITAB2 are your internal tables.
TABLES: LFA1, LFB1.
DATA: ITAB1 LIKE LFA1 OCCURS 0 WITH HEADER LINE,
ITAB2 LIKE LFB1 OCCURS 0 WITH HEADER LINE.
SELECT * FROM LFA1 INTO TABLE ITAB1 WHERE LAND1 = 'IN'.
LOOP AT ITAB1.
CLEAR ITAB2.
SELECT * FROM LFB1 WHERE LIFNR = ITAB1-LIFNR.
ITAB2-LIFNR = ITAB1-LIFNR.
ITAB2-BUKRS = LFB1-BUKRS.
ITAB2-PERNR = LFB1-PERNR.
APPEND ITAB2.
ENDSELECT.
ENDLOOP.
hope this will help you.
Regards,
Vaitheeswaran
2006 Mar 02 6:36 AM
Hi,
Suppose itab1 has fields f1,f2,f3.itab2 has fields f2,f3.
You want to populate itab2 only the records in itab1 in which f1 = 'ABC'(i.e. based on condition).
Here is the way to do that.
wa1 is workarea of itab1.
wa2 is workarea of itab2.
loop at itab1 into wa1 where f1 = 'ABC'.
wa2-f2 = wa1-f2.
wa2-f3 = wa1-f3.
append wa2 to itab2.
endloop.
If you are sure that particular condition occurs in itab1 for only one record,you can use Read statement.
Kindly reward points by clikcing the star on the left of reply,if it helps.
If not,get back for clarifications.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |