‎2008 May 01 8:45 AM
Hi Experts,
here i am printing report output.
in my internal tab there are 10 fields, inthat last field is CURRENCY (amt).
now i want to sum that field at end of first field.
my pease of code is below:
LOOP AT it_display INTO wa_display.
IF wa_display-amount NE 0.
WRITE: /05 wa_display-pspid,
15 wa_display-pspnr1,
35 wa_display-vornr,
45 wa_display-post1,
70 wa_display-verna,
85 wa_display-plfaz,
97 wa_display-plsez,
110 wa_display-gjahr,
125 wa_display-versn,
135 wa_display-wrttp,
140 wa_display-beltp,
145 wa_display-vorga,
152 wa_display-twaer,
160 wa_display-period,
180 wa_display-amount.
ENDIF.
AT END OF pspid.
WRITE: /160 'TOTAL AMOUNT',wa_display-pspid COLOR 3.
SKIP 2.
ENDAT.
ENDLOOP.
how calculate the sum for last field (wa_display-amount).
Thanks in advance,
sudharsan.
‎2008 May 01 8:51 AM
See the following code it might help u :
DATA : SUM TYPE I.
SUM = 0.
WRITE : / 'LIST NO',SY-LSIND.
LOOP AT P_IT_EKPO INTO C_WA_EKPO.
WRITE : / C_WA_EKPO-EBELN, C_WA_EKPO-EBELP ,C_WA_EKPO-MATNR, C_WA_EKPO-NETPR.
SUM = SUM + WA_EKPO-NETPR.
HIDE : C_WA_EKPO-MATNR.
ENDLOOP.
FORMAT COLOR 4.
WRITE : /25 'GRAND TOTAL',SUM.Reward If Found Helpful
‎2008 May 01 8:51 AM
See the following code it might help u :
DATA : SUM TYPE I.
SUM = 0.
WRITE : / 'LIST NO',SY-LSIND.
LOOP AT P_IT_EKPO INTO C_WA_EKPO.
WRITE : / C_WA_EKPO-EBELN, C_WA_EKPO-EBELP ,C_WA_EKPO-MATNR, C_WA_EKPO-NETPR.
SUM = SUM + WA_EKPO-NETPR.
HIDE : C_WA_EKPO-MATNR.
ENDLOOP.
FORMAT COLOR 4.
WRITE : /25 'GRAND TOTAL',SUM.Reward If Found Helpful
‎2008 May 01 9:15 AM
Hi friends thank u for ur help.
i got it and i ve rewarded.
and i ve one more issue on this.
in my table suppose there are 3 fields. like below
field1 field2 field3
-
100 100.01 40
100 100.01.01 50
200 200.01 30
200 200.01.01 70
but iwant output like below
field1 field2 field3
-
100 100.01 40
100 100.01.01 50
Total is -
90
200 200.01 30
200 200.01.01 70
Total is -
100
now am getting output like below:
field1 field2 field3
-
100 100.01 40
Total is -
40
100 100.01.01 50
Total is -
50
200 200.01 30
Total is -
30
200 200.01.01 70
Total is -
70
i want sum at end of field1, but am getting every end of field2.
but in my display loop i ve done like
AT END OF field1 only but why am getting like this.
any help...
Thanks in advance,
sudharsan.
‎2008 May 01 8:52 AM
Try this:
DATA:
W_SUM LIKE wa_display-amount.
LOOP AT it_display INTO wa_display.
IF wa_display-amount NE 0.
ADD wa_display-amount TO w_sum.
WRITE:
/05 wa_display-pspid,
15 wa_display-pspnr1,
35 wa_display-vornr,
45 wa_display-post1,
70 wa_display-verna,
85 wa_display-plfaz,
97 wa_display-plsez,
110 wa_display-gjahr,
125 wa_display-versn,
135 wa_display-wrttp,
140 wa_display-beltp,
145 wa_display-vorga,
152 wa_display-twaer,
160 wa_display-period,
180 wa_display-amount.
ENDIF.
AT END OF pspid.
WRITE: /160 'TOTAL AMOUNT', g_sum, wa_display-pspid COLOR 3.
clear wa_display-amount.
SKIP 2.
ENDAT.
ENDLOOP.Regards,
Suresh Linga.
‎2008 May 01 8:55 AM
hi
at end of <>.
sum
the header line of the internal table will now have the sum of all numeric fields
please reward points