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

Decimal- Currency Division problem

Former Member
0 Likes
2,042

Hi All,

I want to divide the Currency value by decimal value.

When i try to it, it returns the rounded value and not the exact value.

For ex:

data: sal like pa0008-bet01 value '50570.06',

amnt type decimals 2 value '57462.23',

ans TYPE p LENGTH 11 DECIMALS 2.

ans = ( sal / amnt ) * 100.

write:/ ans.

It returns 0.01 and it should be 88.01

Thanx in advance

5 REPLIES 5
Read only

Former Member
0 Likes
937

Hi

The following code it returns 88.01

data: sal like pa0008-bet01 value '50570.06',

amnt type p decimals 2 value '57462.23',

ans type p decimals 2.

ans = ( sal / amnt ) * 100.

write:/ ans.

Just execute the above code.

Regards

Raja.

Read only

Former Member
0 Likes
937

Hii ..check with the amount declaration

amnt type p LENGTH 8 decimals 2 value '57462.23'

Rgds,

Read only

Former Member
0 Likes
937

Hi,

ans type p decimals 2 , would solve ur problem.

Regards.

Read only

Former Member
0 Likes
937

Hi,

In your code change this

amnt type decimals 2 value '57462.23',

to amnt type p decimals 2 value '57462.23',

it will work out.

Read only

Former Member
0 Likes
937

Hi,

Jus try this...

data: sal like pa0008-bet01 value '50570.06',

amnt type p decimals 2 value '57462.23',

ans TYPE p LENGTH 11 DECIMALS 2.

ans = ( sal / amnt ) * 100.

write:/ ans.