‎2009 Feb 09 8:02 AM
hi gays,
My problem is, there are 2 internal table , itab1 and itab2.
in itab1 three variable are declared, in itab2 three variable are declared,
in two tables key field are id.
another table itab3 , i want to add data of itab1 and itab2 in itab3.
how can i do it.
‎2009 Feb 09 8:05 AM
Hi,
The structure of itab3 should contain all the fields of itab1 and itab2.
then u can do it this way,
itab3-field1 = itab1-field1
......
itab3-field3 = itab1-field3
and for 2nd internal table,
itab3-field4 = itab2-field1
.....
itab3-field6 = itab1-field3.
hope it helps.
thanx
Pritha.
‎2009 Feb 09 8:05 AM
Hi,
The structure of itab3 should contain all the fields of itab1 and itab2.
then u can do it this way,
itab3-field1 = itab1-field1
......
itab3-field3 = itab1-field3
and for 2nd internal table,
itab3-field4 = itab2-field1
.....
itab3-field6 = itab1-field3.
hope it helps.
thanx
Pritha.
‎2009 Feb 09 9:03 AM
hi pritha,
when i write itab3-id = itab1-id,but field id is avalable in itab1 and itab2.
in this case what should i do.
‎2009 Feb 09 9:22 AM
In that case u can
loop at itab1.
read table itab2 with key id = itab1-id.
if sy-subrc = 0.
itab3[ ] = itab2 [ ] .
endif.
endloop.
thanx.
PS: you have to loop at a table with more number of records...
Edited by: Pritha Agrawal on Feb 9, 2009 3:02 PM
‎2009 Feb 09 9:41 AM
Suppose f1 is the key in both the tables.
Loop at itab1.
itab3-f1 = itab1-f1.
itab3-f2 = itab1-f2.
itab3-f3 = itab1-f3.
append itab3.
endloop.
Loop at itab2.
move:
itab3-f1 = itab2-f1.
itab3-f2 = itab2-f2.
itab3-f3 = itab2-f3.
append itab3.
endloop.
Delete adjacent duplicates ADJACENT DUPLICATES FROM COMPARING f1.
‎2009 Feb 09 10:08 AM
Hi,
Could you please be more specific,
If the value of ID is same in both the table then what should be done,
The first one should be considered or second one or addition of both in the third table....
Regards,
Siddarth
‎2009 Feb 09 8:52 AM
hi...
make assignment like
t_itab3 = t_itab1.
loop at t_itab3 into w_area.
read table t_itab2 with key w_area-id into w_area.
now modify t_itab3 transporting required field
endloop.
Edited by: Mohit Kumar on Feb 9, 2009 9:53 AM
‎2009 Feb 09 8:58 AM
Hi,
This is simple
Loop at itab1.
move:
itab1-filed1 to itab3-field1.
itab1-filed2 to itab3-field2.
itab1-field3 to itab3-field3.
endloop.
Loop at itab2.
move:
itab2-filed1 to itab3-field1.
itab2-filed2 to itab3-field2.
itab2-field3 to itab3-field3.
endloop.
or of you have declared the intrenal table without header line then
loop at internaltable into workarea.
same code but with wa
append itab.
endloop.Hope this help you.
Pooja