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

moving data from one internal table to another table

Former Member
0 Likes
12,978

Hi,

I want to transfer data from one internal table to another.Both are having different structures.

eg

types : begin of st_stokes,

include type stokes,

count type i,

end of st_stokes.

data : itab1 type table of stokes,

itab2 type table of st_stokes.

itab1 is having the required data.

Thanks

Hi,

I want to transfer data from one internal table to another.Both are having different structures.

eg

types : begin of st_stokes,

include type stokes,

count type i,

end of st_stokes.

data : itab1 type table of stokes,

itab2 type table of st_stokes.

itab1 is having the required data.

Thanks

10 REPLIES 10
Read only

Former Member
0 Likes
1,637

use move corresponding fields of itab1 into itab2.

Read only

Former Member
1,637

try

itab2[] = itab1[].

if it doesn't work, you have to do this:

loop at itab1.

move-corresponding itab1 to itab2.

append itab2.

clear itab2.

endloop.

Regards,

Ravi

Read only

0 Likes
1,637

hi,

Once i move data from itab1 to itab2 and then i am performing:

loop at itab1 into w1.

move-corresponding w1 to w2.

write : / sytabix , w2-col , w2-str.

append w2 to itab2.

clear w2.

endloop.

it shows error that STR and COL is not the component of itab2.

Read only

0 Likes
1,637

Hi..,

What r u trying to write in the loop ???

i hope this meets ur requirement....

types : begin of st_stokes,

include type stokes,

count type i,

end of st_stokes.

data : itab1 type table of stokes,

itab2 type table of st_stokes,

<b>wa1 type stokes,

wa2 type st_stokes.

loop at itab1 into wa1.

move-corresponding wa1 to wa2.

wa2-count = sy-tabix.

append wa2 to itab2.

clear wa2.

endloop.</b>

regards,

sai ramesh

Read only

0 Likes
1,637

Hi,

theirs some value in wa2-str and wa2-col ,which i have to print?

Thanks.

Read only

0 Likes
1,637

hi,

pls chk these fields str and col are available in stokes structure.

Rgds

anversha

Read only

0 Likes
1,637

HI..,

while including a structure i mean INCLUDE <structure> the definition style will change..

<u>check its working here...

the definition of st_stokes should be like this ( when u are using INCLUDE structure )...</u>

<b>types begin of st_stokes.

include type stokes.

types count type i.

types end of st_stokes.</b>

data : itab1 type table of stokes,

itab2 type table of st_stokes,

wa1 type stokes,

wa2 type st_stokes.

loop at itab1 into wa1.

move-corresponding wa1 to wa2.

wa2-count = sy-tabix.

write : wa2-str, wa2-col.

append wa2 to itab2.

clear wa2.

endloop.

plz do rememeber to close the thread, when ur problem is solved !! thanks,

reward points if helpful..

sai ramesh

Read only

anversha_s
Active Contributor
0 Likes
1,637

hi,

check this.

data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1. 

data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2. 

data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final. 


put the date final(merged) internal table
*****************************************
1. loop at itab1.
read table itab2 with key keyfield2 = itab1-keyfield1.
if sy-surc = 0.
itab_final-key_field1 = itab1-keyfield1
itab_final-field1 = itab1-field1.
itab_final-field2 = itab1-keyfield2.
itab_final-field3 = itab2-field2.
itab_final-field4 = itab2-keyfield2.
append itab_final.
clear itab_final.
endif.
endloop.


or


LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop

Rgds

Anversha

Read only

Former Member
0 Likes
1,637

Hi..

assuming ur tables with header lines..

loop at itab1.

move-corresponding itab1 to itab2.

append itab2.

endloop.

Read only

Former Member
0 Likes
1,637

Hi,

Try this:

loop at itab1.

move corrosponding itab1 into itab2.

append itab2.

endloop.