Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table

Former Member
0 Likes
734

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
698

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.

7 REPLIES 7
Read only

Former Member
0 Likes
699

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.

Read only

0 Likes
698

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.

Read only

0 Likes
698

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

Read only

0 Likes
698

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.

Read only

0 Likes
698

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

Read only

Former Member
0 Likes
698

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

Read only

Former Member
0 Likes
698

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