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: 

Rounding Off

Former Member
0 Kudos

Hi,

I need to round off some value. For eg. if the value is .123456(Six Decimal Places) ; answer should be 0.12346(Five Deci Places).

So is there any standard Function module to achieve the same?

Thanks in advance.

Jigar

6 REPLIES 6

Former Member
0 Kudos

Check the FM <b>ROUND</b>

Former Member
0 Kudos

Hi

Check the MATHS function CEIL or FLOOR

following maths functionas are there in SAP:

abs -Absolute value of the argument arg

sign- Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.

ceil -Smallest integer number that is not smaller than the value of the argument arg.

floor- Largest integer number that is not larger than the value of the argument arg.

trunc- Value of the integer part of the argument arg

frac- Value of the decimal places of the argument arg

Regards

Anji

Former Member
0 Kudos

write field to charvar decimals 5.

*declare a charecter type variable and move the field to that variable in above way....

Regards

vasu

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try these FM.

FI_ROUND_AMOUNT

ROUND

ROUND_AMOUNT

HR_NZ_ROUNDING_DECIMALS

Regards,

Ferry Lianto

Former Member
0 Kudos

Hi

THanks a lot for your quick response.

But as per my requirement;

there is a char data type with lenght 16 in which last seven digits are to considered as if they are after decimal point.

For eg. value is : 0000000000011173 ; then First nine charaters 000000000 are before decimal point and last seven characters 0011173 are after decimal point. So I would like to have answer as 000000000.00112. i.e we need to round of the given value such a way that only 5 digits are there after decimal point.

Thanks in advance

Former Member
0 Kudos

Hi,

Try with this:

DATA pack TYPE p VALUE '123.456'

DECIMALS 3.

WRITE pack DECIMALS 2.

WRITE: / pack ROUND -2,

/ pack ROUND -1,

/ pack ROUND 1,

/ pack ROUND 2.

Regards,

Bhaskar