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

itab

Former Member
0 Likes
698

hi,

i have 2 fields in itab1 and 3 fields in itab2 with data.

i want a itab where all 5 fields with data should be there in this new itab.

how i will do it?

can any one help me?

thanks

Santosini

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
681

Hi,

Suppose if you have mininmum 2 fields same in both the itabs then you can pass.

ITAB[] = ITAB2[].

LOOP AT ITAB1.

MOVE : ITAB2-field1 TO itab-field1,

ITAB2-field2 TO itab-field2,

APPEND ITAB.

CLEAR ITAB.

ENDLOOP.

5 REPLIES 5
Read only

Former Member
0 Likes
682

Hi,

Suppose if you have mininmum 2 fields same in both the itabs then you can pass.

ITAB[] = ITAB2[].

LOOP AT ITAB1.

MOVE : ITAB2-field1 TO itab-field1,

ITAB2-field2 TO itab-field2,

APPEND ITAB.

CLEAR ITAB.

ENDLOOP.

Read only

0 Likes
681

Hi,

Suppose if you have mininmum 2 fields same in both the itabs then you can pass.

ITAB[] = ITAB2[].

LOOP AT ITAB1.

MOVE : ITAB2-field1 TO itab-field1,

ITAB2-field2 TO itab-field2,

APPEND ITAB.

CLEAR ITAB.

ENDLOOP.

Read only

Former Member
0 Likes
681

Hi,

You can do like this.

Itab1 with 2 fields.(Heeader data)

itab2 with 3 fields.( Item data)

itab3 wiht 5 fields.

sort itab1 by key.

sort itab2 by key.

loop at itab2.

read table itab1 with key field1 = itab2-field binary search.

if sy-subrc = 0.

move itab2 data to itab3.

move itab1 data to itab3

append itab3.

endif.

endloop.

hope this helps.

Reward if helpful.

Regards

Sourabh

Read only

Former Member
0 Likes
681

Hi,

Delcare the 3 internal tables.

If there is a common field in itab1 and itab2, then

loop at itab1.

move-corresponding itab1 to itab3.

read table itab2 with itab1-field = itab2-field.

"field is common field

if sy-subrc = 0.

itab3-field4 = itab2-field1.

itab3-field5 = itab2-field2.

append itab3.

else.

append itab3.

itab3-field4 = itab2-field1.

itab3-field5 = itab2-field2

append itab3.

endif.

endloop.

reward.

Read only

Former Member
0 Likes
681

thank you its been solved.