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

during amount calculation how to stop rounding

Former Member
0 Likes
3,245

Dear Freinds,

i have an amount as 121.539 , now whenf i divided by 10 it is becoming rounding to 12.154 automatically. This is not acceptable during the testing they have said it has to 12.153 only .

The data type of amount is 3 decimals type. Could any one let me know how can i stop rounding and get exactly as 12.153 only

instead of 12.154.

regards

ravi

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
1,459

Hi Ravi, <li>Try this way.

REPORT ztest_notepad.

DATA:value1 TYPE p DECIMALS 3 VALUE '121.539'.
DATA:value2 TYPE c LENGTH 20.
DATA:len    TYPE i.

value2 = value1 / 10.
CONDENSE value2.
len = STRLEN( value2 ).
len = len - 5.
value2+len(5) = value2+len(4).
WRITE value2.
Thanks Venkat.O

Dear Freinds,

i have an amount as 121.539 , now whenf i divided by 10 it is becoming rounding to 12.154 automatically. This is not acceptable during the testing they have said it has to 12.153 only .

The data type of amount is 3 decimals type. Could any one let me know how can i stop rounding and get exactly as 12.153 only

instead of 12.154.

regards

ravi

3 REPLIES 3
Read only

venkat_o
Active Contributor
0 Likes
1,460

Hi Ravi, <li>Try this way.

REPORT ztest_notepad.

DATA:value1 TYPE p DECIMALS 3 VALUE '121.539'.
DATA:value2 TYPE c LENGTH 20.
DATA:len    TYPE i.

value2 = value1 / 10.
CONDENSE value2.
len = STRLEN( value2 ).
len = len - 5.
value2+len(5) = value2+len(4).
WRITE value2.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,459

Dear Venkat,

Thanks allot it surved the purpose of problem, but i have one question can you explain me what exactly 5 means in the logic

len = len - 5.

i.e why you have taken 5 and specific reason.

this is only point i dint understood.

regard

madhu

Read only

venkat_o
Active Contributor
0 Likes
1,459

Hi Madhu, <li> 4 decimal places and decimal point. After dividing, you will get 4 decimal places right. Thanks, Venkat.O