‎2007 Jun 20 5:22 PM
I have 4 charecter fields C1,C2,C3,C4 and 2 Numeric Fields N1 and N2. I need to sum N1 and N2 Numeric fields for unique C1 and C2 charecter fields. How can i do that? Kindly help me
‎2007 Jun 20 5:50 PM
try this
sort itab by c1 c2.
loop at itab.
at end of C2.
SUM.
endat.
endloop.
‎2007 Jun 20 5:50 PM
try this
sort itab by c1 c2.
loop at itab.
at end of C2.
SUM.
endat.
endloop.
‎2007 Jun 20 6:03 PM
‎2007 Jun 20 6:59 PM
Sorry it works... I need to put the fields in sequnce C1, C2 in the structure. If i change the sequence like C1, C3, C2 in structure AT END OF C2 dosent works in the loop. Thanks for your help
‎2007 Jun 20 6:03 PM
Hi,
Please try this something like this.
data: begin of itab2 occurs 0,
c1c2(10),
n1(10) type n,
n2(10) type n.
data: end of itab2.
sort itab by c1 c2 ascending.
loop at itab.
itab2-c1c2(5) = itab-c1.
itab2-c1c2+5(5) = itab-c2.
itab2-n1 = itab-n1.
itab2-n2 = itab-n2.
collect itab2.
endloop.
loop at itab2.
write: / itab2-c1c2(5), itab2-c1c2+5(5), itab2-n1, itab2-n2.
endloop.
Now your internal table ITAB2 has sum of field N1 and N2 of unique C1 and C2.
Regards,
Ferry Lianto