‎2008 Mar 21 9:28 AM
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
‎2008 Mar 21 9:45 AM
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.
‎2008 Mar 21 9:45 AM
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.
‎2008 Mar 21 9:46 AM
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.
‎2008 Mar 21 9:57 AM
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
‎2008 Mar 21 10:07 AM
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.
‎2008 Mar 21 10:11 AM