Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

gross amount

Former Member
0 Likes
895

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.

3 REPLIES 3
Read only

Former Member
0 Likes
824

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

Read only

Former Member
0 Likes
824

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

Read only

Former Member
0 Likes
824

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.