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

This is regarding internal tables

Former Member
0 Likes
556

Hi to all,

Here is my requirement.

i have 3 internal tables,

it_itab1 having fields f1,f2

it_itab2 having fields f3,f4.

it_final having fields f1,f2,f3,f4.

now i want to move data from it_itab1,it_itab2 to final internal table it_final.

how to do this,

Thanks and regards,

s

Hi to all,

Here is my requirement.

i have 3 internal tables,

it_itab1 having fields f1,f2

it_itab2 having fields f3,f4.

it_final having fields f1,f2,f3,f4.

now i want to move data from it_itab1,it_itab2 to final internal table it_final.

how to do this,

Thanks and regards,

s

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
539

Hi,



loop at itab1.
  read table itab_final with key < your key field> = itab1-keyfield.
  if sy-subrc eq 0.
     move-corresponding itab1 to itab_final.
     modify itab_final.
  else.
     move-corresponding itab1 to itab_final.
    append itab_final.  
  endif.
endloop.

loop at itab2
  read table itab_final with key < your key field> = itab2-keyfield.
  if sy-subrc eq 0.
     move-corresponding itab2 to itab_final.
     modify itab_final.
  else.
     move-corresponding itab2 to itab_final.
    append itab_final.  
  endif.
endloop.

Read only

Former Member
0 Likes
539

Hi

General statements to move data from one internal table to another internal table


-->move-corresponding itab1 to itab2.
-->move itab1 to itab2.
-->itab2 = itab1

and for your case write as

it_itab1 = it_final.

after your select statement

and then t_itab2 = it_final.

afetr your second select statement

Regards

Pavan

Read only

Former Member
0 Likes
539

Hi Swami,

Loop at it_tab1.

it_final-f1 = it_tab1-f1.

it_final-f2 = it_tab1-f2.

append it_final.

endloop.

loop at it_tab2.

it_final-f3 = it_tab2-f3.

it_final-f4 = it_tab2-f4.

modify it_final.

endloop.

Use like this way its easy and clear.

Thanks,

Sakthi C

*Rewards if useful*

Read only

Former Member
0 Likes
539

It all depends on the field's contents. Based on which one is the key field, the selection statements vary.

The most common method followed here is:

LOOP AT it_itab1.

READ TABLE it_itab2 INDEX sy-tabix.

MOVE-CORRESPONDING: it_itab1 TO it_final,

it_tab2 TO it_final.

APPEND it_final.

CLEAR it_itab1, it_tab2, it_final.

ENDLOOP.