Application Development 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: 

Assigning data from one internal table to other.

Former Member
0 Kudos

Hi Experts,

Below is my code.

FIELD-SYMBOLS: <lfs_get_data> TYPE gty_outtab.

FIELD-SYMBOLS: <lfs_final> TYPE gty_final.

FIELD-SYMBOLS: <lfs_kostl> TYPE gty_kostl.

*Make sure gt_final is not empty.

CHECK NOT gt_final[] IS INITIAL.

*Get Cost Center description

SELECT kostl ktext INTO TABLE gt_kostl

FROM cskt

FOR ALL ENTRIES IN gt_final

WHERE kostl = gt_final-kostl

AND spras = sy-langu

AND datbi GE sy-datum

AND kokrs = gc_kokrs_1000.

LOOP AT gt_outtab ASSIGNING <lfs_get_data>.

*Read the Hash table gt_ktext to get the related Cost Center Text

READ TABLE gt_kostl ASSIGNING <lfs_kostl> WITH TABLE KEY kostl = <lfs_get_data>-kostl.

IF sy-subrc = 0.

<lfs_get_data>-ktext = <lfs_kostl>-ktext.

ENDIF.

ENDLOOP.

Now before the loop statement I have to get the data from one internal table to other. Here my gt_outtab is empty. Now I have to move the data from gt_final to gt_outtab. Please help me.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

Take ITAB1 and ITAB2 ,Simply u can copy the from one internal table to another by the follwoung statement

ITAB1[] = ITAB2[] --the entire contnet will be copied

ITAB1 = ITAB2 -the header line data will be copied

if the both internal tables are of differrent structures use loop statement ans assign corresponing fields like below

loop at ITAB1 .

itab2-field1 = itab1-field1.

itab2-field2 = itab1-field2.

endloop.

2 REPLIES 2

Former Member
0 Kudos

If both the internal tables are in the same structure then

gt_final[] = gt_outtab[]

If both are different with some similar fields then

loop at gt_final into gs_final.

move: gs_final-field1 to gs_outtab.

gs_final-field2 to gs_outtab.

Append gs_outtab to gt_outtab.

Clear gs_outtab, gs_final.

endloop.

Thanks,

Srinivas

Former Member
0 Kudos

hi,

Take ITAB1 and ITAB2 ,Simply u can copy the from one internal table to another by the follwoung statement

ITAB1[] = ITAB2[] --the entire contnet will be copied

ITAB1 = ITAB2 -the header line data will be copied

if the both internal tables are of differrent structures use loop statement ans assign corresponing fields like below

loop at ITAB1 .

itab2-field1 = itab1-field1.

itab2-field2 = itab1-field2.

endloop.