2007 Sep 20 9:28 AM
hallow
i have table with emp miss for month and i wont to add another line with sum of miss days for month how i can do that ?
kostl month1 month2 month3 month4 month5 month6
1000-10 532 456 503 453 522 500
1000-11 23 20 21 19 22 20
for this table ccmissdays i wont to add line with bold (sum)
kostl month1 month2 month3 month4 month5 month6
1000-10 532 456 503 453 522 500
1000-11 23 20 21 19 22 20
<b>555 476 524 472 544 520</b>
Best regards
2007 Sep 20 9:32 AM
LOOP at itab into wa_itab.
at last.
sum.
lz_month1 = wa_itab-month1.
lz_month2 = wa_itab-month2.
.
.
.
endat.
write : / here display your records lz_month1 and lz_month2 will be having the sum.
endloop.
2007 Sep 20 9:32 AM
Try this one, after this, you should have a sum of all the values in your internal table inside the table.
loop at table.
at last.
sum .
append table.
endat.
endloop.
But why would you do this if you can just write or assign the total values of each field inside the code
at last...endat.
2007 Sep 20 9:32 AM
LOOP at itab into wa_itab.
at last.
sum.
lz_month1 = wa_itab-month1.
lz_month2 = wa_itab-month2.
.
.
.
endat.
write : / here display your records lz_month1 and lz_month2 will be having the sum.
endloop.
2007 Sep 20 9:36 AM
loop at iatb.
at last.
sum .
itab-month1 = itab-month1.
itab-month2 = itab-month2.
itab-month3 = itab-month3.
itab-month4 = itab-month4.
itab-month5 = itab-month5.
itab-month6 = itab-month6.
append itab..
endat.
endloop.
Regards
vasu
2007 Sep 20 9:38 AM
hi mukesh
assume i have more than 2 lines (maybe 10) it work also?
Regards
2007 Sep 20 9:39 AM
Hi TAL,
Yes it will work for any number of lines.
SUM command calculates SUM for all the records of Internal table but it should be Numeric.
Regards,
Mukesh Kumar
2007 Sep 20 9:40 AM
hi vasu
assume i have more than 2 lines (maybe 10) it work also?
Regards
2007 Sep 20 9:43 AM
Hi TAL....
ya it will work....
as we r giving at last....and SUM adds up everything....
Regards
Vasu
2007 Sep 20 9:51 AM
hi vasu
i try your saggstion and its work partly ,i have sum but the loop never stop and i have dump, i wont just to to sum for the lines i have in table this is part of what i get
1000-101 532 456 503
1000-111 23 20 21
********** 555 476 524
********** 1110 952 1048
********** 2220 1904 2096
i dont wont 4 and five line
Best regards
2007 Sep 20 9:52 AM
hi mukesh
i try your saggstion and its work partly ,i have sum but the loop never stop and i have dump, i wont just to to sum for the lines i have in table this is part of what i get
1000-101 532 456 503
1000-111 23 20 21
********** 555 476 524
********** 1110 952 1048
********** 2220 1904 2096
i dont wont 4 and five line
Best regards
2007 Sep 20 10:15 AM
loop at itab.
at last.
sum.
itab-month2 = itab-month2.
itab-month3 = itab-month3.
itab-month4 = itab-month4.
itab-month5 = itab-month5.
itab-month6 = itab-month6.
<b>clear itab-month1.
append itab.
clear itab.
exit.</b>
endat.
endloop.
Give EXIT. after appending.....
Regards
Vasu
2007 Sep 20 9:36 AM
Hi,
t_month1 = t_month2 =t_month3 = t_month4 = t_month5 =t_month6 =0.
loop at itab
t_month1 = t_month1+itab-month1.
t_month2 = t_month2+itab-month2.
t_month3 = t_month3+itab-month3.
t_month4 = t_month4+itab-month4.
t_month5 = t_month5+itab-month5.
t_month6 = t_month6+itab-month6.
l_index = sy-tabix.
endloop.
clear itab.
l_index = l_index + 1.
itab-mnth1 = t_month1.
itab-mnth2 = t_month2.
itab-mnth3 = t_month3.
itab-mnth4 = t_month4.
itab-mnth5 = t_month5.
itab-mnth6 = t_month6.
insert itab index l_index.
reward if solved problem**
2007 Sep 20 9:55 AM
loop at itab.
zmonth1_sum = itab-month1 + zmonth1_sum.
zmonth2_sum = itab-month2 + zmonth2_sum.
zmonth3_sum = itab-month3 + zmonth3_sum.
zmonth4_sum = itab-month4 + zmonth4_sum.
zmonth5_sum = itab-month5+zmonth5_sum.
zmonth6_sum = itab-month6 + zmonth6_sum.
endloop.
itab-kostl = ' '.
itab-month1 = zmonth1.
itab-month2 = zmonth2.
itab-month3 = zmonth3.
itab-month4 = zmonth4.
itab-month5 = zmonth5.
itab-month6 = zmonth6.
append itab.