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: 

use of Round function

Former Member
0 Kudos

Hi,

I have a requirement to round off the values. The round offed values should store in another variable.

Can u give function module or any operator to achieve this one.

Ex v1 = 12.567.

round of v1 = v2 = 13.

Rewards as per answer.

1 ACCEPTED SOLUTION

former_member188827
Active Contributor
0 Kudos

data zval type p DECIMALS 3.

data zval1 TYPE p DECIMALS 0.

zval = '12.567'.

zval1 = zval.

WRITE / zval1.

5 REPLIES 5

former_member188827
Active Contributor
0 Kudos

data zval type p DECIMALS 3.

data zval1 TYPE p DECIMALS 0.

zval = '12.567'.

zval1 = zval.

WRITE / zval1.

Former Member
0 Kudos

Hi,

Check,

DATA pack TYPE p VALUE '12.567'.

WRITE pack NO-GROUPING ROUND 0 DECIMALS 0.

reward point if useful.

Former Member
0 Kudos

Hi,

J_1I6_ROUND_TO_NEAREST_AMT

This FM rounds the number.

but the input shud b in ','.

for eg: input = 12,5 instead of 12.5

output= 13

Also, try this method:

data : a type p decimals 2,

b type i.

a = '10.20'.

b = abs( a ).

write : / b.

a = '10.50'.

b = abs( a ).

write : / b.

Former Member
0 Kudos

data:

w_pack_ip TYPE p decimals 3 VALUE '12.567',

w_pack_op TYPE p decimals 3.

w_pack_op = ceil( w_pack_ip ).

write: w_pack_op.

Alternatively u can also make use of the FM <b>'ROUND</b>'

varma_narayana
Active Contributor
0 Kudos

Hi Kiran.

This is the way.

Data : v1 type p decimals 2 value '123.45',

v2 type p decimals 2.

write v1 to v2 decimals 0. "Value will be Rounded off automatically

WRITE:/ V2.

reward if Helpful.