06-06-2008 5:42 AM
hi all,
how we can copy internal table itab1 into internal table itab2
itab1 having 2 fileds and itab2 having 3 fields.
now, i want an internal tbale who is having 5 filds i.e 2 fields of itab1 and 3 fields of itab2
so, we clubed these fileds into an internal table.
06-06-2008 6:15 AM
Hi Vipin,
Check this ex:
ITAB1 is having fields "A","B", "C".
ITAB2 is having fields "A","D", "E".
Create i_final internal table to have all fields of 2 internal tables.
i_final is having "A","B","C","D","E".
SORT itab1 ,itab2 by A
LOOP AT ITAB1.
READ TABLE itab2 WITH KEY a = itab1-a BINARY
SEARCH.
IF SY-SUBRC EQ 0.
MOVE : itab1-a TO i_final-a,
itab1-b TO i_final-b,
itab1-c TO i_final-c,
itab2-d TO i_final-d,
itab2-e TO i_final-e.
APPEND i_final.
ENDIF.
ENDLOOP.
06-06-2008 5:44 AM
06-06-2008 5:53 AM
Hi,
declare work areas of the internal table types and read the internal table data in to work areas usin read statement or loop ..endloop stament and then move the the corresponding fields between the work areas and then append the work areas to their corresponding internal tables.
06-06-2008 6:15 AM
Hi Vipin,
Check this ex:
ITAB1 is having fields "A","B", "C".
ITAB2 is having fields "A","D", "E".
Create i_final internal table to have all fields of 2 internal tables.
i_final is having "A","B","C","D","E".
SORT itab1 ,itab2 by A
LOOP AT ITAB1.
READ TABLE itab2 WITH KEY a = itab1-a BINARY
SEARCH.
IF SY-SUBRC EQ 0.
MOVE : itab1-a TO i_final-a,
itab1-b TO i_final-b,
itab1-c TO i_final-c,
itab2-d TO i_final-d,
itab2-e TO i_final-e.
APPEND i_final.
ENDIF.
ENDLOOP.