2006 Dec 30 8:03 AM
hi all,
i want to calculate the gross amount , i tried with a logic but i m getting gross amount at item level i.e for each record in the int table.
i have an internal table named it_item, its fields are it_item-amount, it_item-grossamount and ....
please tell me how to calculate the gross amount.
hi all,
i want to calculate the gross amount , i tried with a logic but i m getting gross amount at item level i.e for each record in the int table.
i have an internal table named it_item, its fields are it_item-amount, it_item-grossamount and ....
please tell me how to calculate the gross amount.
2006 Dec 30 8:20 AM
Just do the normal additions during the loop iteration and get the total into a variable , and if u want to display it at the last then try to get it by at last /endat (control breaks )in the report .
If its in ALV then use the do_sum option in the list during the field catalog.
can u post ur code so that we can see where u r getting the error ?
regards,
Vijay
2006 Dec 30 8:57 AM
just delete the column it_item-grossamount
now your it_items contain items name and amount.
sort it_items by items.
loop at it_items.
at end of it_items-item.
sum.
write : / 'Sub total' ,it_items-amount.
end at.
at last.
sum.
write : / 'Gross Total', it_items-amount.
end at.
endloop.
regards
shiba dutta
Message was edited by:
SHIBA DUTTA
2006 Dec 30 9:13 AM
Use AT LAST then give SUM. and get the gross amount from the amount field.
Dont forget to take the value from the field within that control break statements.
other wise it will restore the old value outside of it.
Take the example given.
in that it calculates the gross amount of sno.
and the field you want to sum must be number field. no character.
REPORT Z_TESTYUVA .
DATA : Begin of it_sno occurs 0,
sno TYPE i,
value(2) TYPE c,
END of it_sno.
DATA : count Type i Value 0,
count1 Type i Value 0,
sno_temp Type i.
it_sno-sno = 123.
it_sno-value = 'A1'.
Append it_sno.
clear it_sno.
it_sno-sno = 123.
it_sno-value = 'A2'.
Append it_sno.
clear it_sno.
it_sno-sno = 123.
it_sno-value = 'A3'.
Append it_sno.
clear it_sno.
it_sno-sno = 124.
it_sno-value = 'A2'.
Append it_sno.
clear it_sno.
it_sno-sno = 125.
it_sno-value = 'A1'.
Append it_sno.
clear it_sno.
it_sno-sno = 125.
it_sno-value = 'A3'.
Append it_sno.
clear it_sno.
it_sno-sno = 128.
it_sno-value = 'A1'.
Append it_sno.
clear it_sno.
LOOP at it_sno.
AT LAST.
SUM.
sno_temp = it_sno-sno.
ENDAT.
ENDLOOP.
Write sno_temp.
*result is 871.
For yours it will be like this
LOOP at it_item.
AT LAST.
SUM.
gross_amount = it_item-amount.
ENDAT.
ENDLOOP.
it_item-grossamount = gross_amount.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |