‎2009 Apr 24 6:53 AM
Hi experts,
I have intenal table like...
aa 10 20
bb 11 21
cc 13 30
aa 22 33
bb 45 22
cc 12 22
here i want to add the same record in one line like...
aa 10 20 22 33
bb 11 21 45 22
cc 13 30 12 22
Plese help me........
‎2009 Apr 24 7:03 AM
Hello,
sort table by Field one whihc contains that aa, bb etc....
table will loo like this
F1 F2 F3 F4 F5
aa 10 20
aa 22 33
bb 11 21
bb 45 22
cc 13 30
cc 12 22
data : var1 type < field of type aa, bb etc..)
loop at itab .
if var1 is initial.
var1= itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Elseif var1 <> itab-F1.
append ittab1.
var1= itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Else if var1 = itab-F1.
itab1-F4 = itab-F2.
itab1-F5 = itab-F3.
endif.
Endloop.
hope this helps you..... close the post if u get the solution
‎2009 Apr 24 6:57 AM
Hello,
use the following:
types : begin of ty,
id type c,
n1 type i,
n2 type i,
n3 type i,
n4 type i,
end of ty.
data : itab type table of ty initial size 0,
wa type ty.
sort itab by id.
loop at itab into wa..
if wa-id eq wa-id.
wa-n3 = wa-n1.
wa-n4 = wa-n2.
append wa to itab.
endif.
endloop
sort itab by id.
deleet adjacent duplicates from itab comparing id.
Regards,
Mansi.
Edited by: SAP USER on Apr 24, 2009 8:00 AM
‎2009 Apr 24 7:03 AM
Hello,
sort table by Field one whihc contains that aa, bb etc....
table will loo like this
F1 F2 F3 F4 F5
aa 10 20
aa 22 33
bb 11 21
bb 45 22
cc 13 30
cc 12 22
data : var1 type < field of type aa, bb etc..)
loop at itab .
if var1 is initial.
var1= itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Elseif var1 <> itab-F1.
append ittab1.
var1= itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Else if var1 = itab-F1.
itab1-F4 = itab-F2.
itab1-F5 = itab-F3.
endif.
Endloop.
hope this helps you..... close the post if u get the solution
‎2009 Apr 24 7:12 AM
jst copy paste n execute.......
types : begin of ty_tab,
f1 type char2,
f2 type char2,
f3 type char2,
f4 type char2,
f5 type char2,
End of ty_tab.
data : itab type ty_tab occurs 0 with header line.
data : itab1 type ty_tab occurs 0 with header line.
data : var1 type char2.
itab-f1 = 'aa'.
itab-f3 = '10'.
itab-f2 = '20'.
append itab.
itab-f1 = 'bb'.
itab-f3 = '11'.
itab-f2 = '21'.
append itab.
itab-f1 = 'cc'.
itab-f3 = '12'.
itab-f2 = '22'.
append itab.
itab-f1 = 'bb'.
itab-f3 = '11'.
itab-f2 = '21'.
append itab.
itab-f1 = 'aa'.
itab-f3 = '30'.
itab-f2 = '40'.
append itab.
itab-f1 = 'bb'.
itab-f3 = '31'.
itab-f2 = '41'.
append itab.
itab-f1 = 'bb'.
itab-f3 = '32'.
itab-f2 = '42'.
append itab.
sort itab by f1.
loop at itab .
if var1 is initial.
var1 = itab-F1.
itab1-F1 = itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Elseif var1 <> itab-F1.
append itab1.
var1 = itab-F1.
itab1-F1 = itab-F1.
itab1-F2 = itab-F2.
itab1-F3 = itab-F3.
Elseif var1 = itab-F1.
itab1-F4 = itab-F2.
itab1-F5 = itab-F3.
endif.
Endloop.