Application Development 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: 

DIVISON OF TWO FIELDS

Former Member
0 Kudos
111

HI Friends,

i fetch some fields from database table.. and i load into intenal table...

now i want to do caliculation on those fields...

for example : i want to caliculate Total currecncy / Quantity so, i will get unit cost...

for this what can i write the syntax..

what i wrote is i define one variable as ZRESULT that data type as I

after fetch the data i use this syntax : Zresult = ITAB - TotalCost / ITAB - Quantity

but data was not caliculated.. based on these... PLZ CORRECT ME..

give me the correct syntax..

thanks

Babu

1 ACCEPTED SOLUTION

Former Member
0 Kudos
76

BABU ,

what is the type of Zresults ?

it should be like this

data: zresults(15) type p decimals 3

Zresult = ( ITAB - TotalCost / ITAB - Quantity ).

Regards

Peram

4 REPLIES 4

Former Member
0 Kudos
76

try this,

data : Zresult type p decimals 2.

loop at itab.

if not ITAB-Quantity eq 0.
Zresult = ITAB-TotalCost  /  ITAB-Quantity.
endif.

endloop.

Former Member
0 Kudos
77

BABU ,

what is the type of Zresults ?

it should be like this

data: zresults(15) type p decimals 3

Zresult = ( ITAB - TotalCost / ITAB - Quantity ).

Regards

Peram

Former Member
0 Kudos
76

hi,

ur internal table is with header line then try like this as

loop at itab.

itab-tot = iITAB - TotalCost / ITAB - Quantity.

update itab.

endloop.

or if ur internal table is without hedaer line then

loop at itab into wa.

wa-tot = wa - TotalCost / wa - Quantity.

modify itab from wa.

endloop.

if useful reward some points.

with regards,

Suresh Aluri.

Former Member
0 Kudos
76

Thanks

i was solve the problem..

regards

Babu