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: 

appending data in two tables

Former Member
0 Kudos

Hi techies,

I hav one table with five columns like below

f1 f2 f3 ... f5

01 08 04 04

03 09 02 00

06 01 07 05

But frnds i want to store it in another table as

f6

01

03

06

08

09

01

.

.

.

like this...

Frnds can anyone help me to get the logic...

thanking u all.

regards,

sanjay

1 ACCEPTED SOLUTION

Former Member
0 Kudos

loop at itab.

itab1-f = itab-f1.

append itab1.

itab1-f = itab-f2.

append itab1.

itab1-f = itab-f3.

append itab1.

<like this>

endloop.

regards

shiba dutta

5 REPLIES 5

Former Member
0 Kudos

loop at itab.

itab1-f = itab-f1.

append itab1.

itab1-f = itab-f2.

append itab1.

itab1-f = itab-f3.

append itab1.

<like this>

endloop.

regards

shiba dutta

Former Member
0 Kudos

Hi,

Try like this:

loop at itab.

it1-val = itab-v1.

append it1.

it2-val = itab-v2.

append it2.

it3-val = itab-v3.

append it3.

endloop.

append lines of it2 to it1.

append lines of it3 to it1.

Regards,

Subramanian

Former Member
0 Kudos

hi

i think u can use move-corresponding itab1 to itab2

and then can append the other field

loop at itab2.

itab2-f6 = 'x'.

append itab2.

endloop.

Former Member
0 Kudos

Hi sanjay,

Look at the following code segment.

I tried this one and it suits for your requirement.

data:

begin of itab1 occurs 0,

f1 type i,

f2 type i,

f3 type i,

f4 type i,

f5 type i,

end of itab1,

begin of itab2 occurs 0,

f1 type i,

end of itab2.

clear itab1.

itab1-f1 = 1.

itab1-f2 = 2.

itab1-f3 = 3.

itab1-f4 = 4.

itab1-f5 = 5.

append itab1.

clear itab1.

itab1-f1 = 6.

itab1-f2 = 7.

itab1-f3 = 8.

itab1-f4 = 9.

itab1-f5 = 10.

append itab1.

clear itab1.

itab1-f1 = 11.

itab1-f2 = 12.

itab1-f3 = 13.

itab1-f4 = 14.

itab1-f5 = 15.

append itab1.

<b>loop at itab1.

itab2-f1 = itab1-f1.

append itab2.

itab2-f1 = itab1-f2.

append itab2.

itab2-f1 = itab1-f3.

append itab2.

itab2-f1 = itab1-f4.

append itab2.

itab2-f1 = itab1-f5.

append itab2.

endloop.</b>

<b>Reward if helpful.</b>

Regards,

Sandhya

Former Member
0 Kudos

data:

begin of fs_t1,

f1 type i,

f2 type i,

f3 type i,

f4 type i,

f5 type i,

end of fs_t1.

data:

t_t1 like standard table of fs_t1.

data:

begin of fs_t2,

f6 type i,

end of fs_t1.

data:

t_t2 like standard table of fs_t2.

fs_t1-f1 = 01.

fs_t1-f2 = 08.

fs_t1-f3 = 04.

fs_t1-f4 = 04.

fs_t1-f5 = 04.

append fs_t1 to t_t1.

clear fs_t1.

fs_t1-f1 = 03.

fs_t1-f2 = 09.

fs_t1-f3 = 02.

fs_t1-f4 = 02.

fs_t1-f5 = 00.

append fs_t1 to t_t1.

clear fs_t1.

fs_t1-f1 = 06.

fs_t1-f2 = 01.

fs_t1-f3 = 01.

fs_t1-f4 = 07.

fs_t1-f5 = 05.

append fs_t1 to t_t1.

loop at t_t1 into fs_t1.

fs_t2-f6 = fs_t1-f1.

append fs_t2 to t_t2.

fs_t2-f6 = fs_t1-f2.

append fs_t2 to t_t2.

fs_t2-f6 = fs_t1-f3.

append fs_t2 to t_t2.

fs_t2-f6 = fs_t1-f4.

append fs_t2 to t_t2.

fs_t2-f6 = fs_t1-f5.

append fs_t2 to t_t2.

endloop.

regards,

kiran kumar k