09-22-2006 1:12 PM
hi experts,
i got the values in internal table.
key activ hsl csale
01 koae 786.88 800.00
01 rmwl 567.77 987.55
01 koae 100.55 800.00
01 sd00 432.55 234.66
02 koae 650.00 400.00
02 rmwl 156.44 412.88
02 koae 700.00 500.00
02 sd00 100.77 500.88
i want summation of hsl and csale where same key and same activ and i need to put in another jtab internal table.
that means jtab values nust be like this.
key activ hsl csale
01 koae 886.88 1600.00
02 koae 1350.00 900.00
for this how can i write the code can anybody help me.
answer will be rewarded.
venkat.
09-22-2006 1:14 PM
Hi,
If key is a character field, collect itab will work.
Just put collect itab instead of append itab and check the output.
regards,
senthil
09-22-2006 1:22 PM
Hi
Check this code,
data : begin of itab occurs 0,
key(2),
activ(4),
hsl type p decimals 2,
csale type p decimals 2,
end of itab.
itab-key = '01'.
itab-activ = 'koae'.
itab-hsl = '786.88'.
itab-csale = '800.00'.
collect itab.
itab-key = '01'.
itab-activ = 'rmw1'.
itab-hsl = '567.77'.
itab-csale = '987.55'.
collect itab.
itab-key = '01'.
itab-activ = 'koae'.
itab-hsl = '100.55'.
itab-csale = '800.00'.
collect itab.
add all your values like this and check
itab-key = '01'.
itab-activ = 'koae'.
itab-hsl = '786.88'.
itab-csale = '800.00'.
collect itab.
loop at itab.
write 😕 itab-key, itab-activ, itab-hsl, itab-csale.
endloop.
Regards,
Senthil
09-22-2006 1:14 PM
09-22-2006 1:15 PM
sort itab.
loop at itab
at end of activ.
sum.
move-correspoding itab to itab1.
append itab1.
endat.
endloop.
09-22-2006 1:18 PM
Hi,
First sort the internal table depending upon the fields and then using AT NEW u can find the sum.
sort itab by key activ.
loop at itab.
w_hsl = w_hsl + hsl.
w_cscale = w_cscale + cscale
at new activ.
here append the data into another table
endat.
endloop.
Regards,
Vibha
Reward points if it helps
09-22-2006 1:35 PM
hi,
try this,
sort ftab by key activ.
loop at ftab.
clear: m, n.
at new active.
m = ftab-activ.
loop at ftab where active = m.
n = n + 1.
endloop.
if n > 1.
move ftab-... to btab-.....
move ftab-... to btab-.....
move ftab-... to btab-.....
collect btab.
endif.
endat.
endloop.