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

Rounding Value

Former Member
0 Likes
1,175

Hi,

Is there any Function module to round the values ie. Value = 2.49 then i want it as 3....

Thanks in advance

9 REPLIES 9
Read only

Former Member
0 Likes
1,119

<b>n = floor( m ). WRITE: / 'FLOOR:', n.</b>

Also see this FM

<b>HR_NZ_ROUNDING_DECIMALS

ROUND</b>

Read only

Former Member
0 Likes
1,119

Use CEIL.

Usage:

DATA : p TYPE p DECIMALS 2 VALUE '2.49'.

DATA i TYPE i.

i = CEIL( p ).

WRITE : i.

Read only

Former Member
0 Likes
1,119

Hi,

Use the function module 'HR_NL_ROUNDING'

Regards,

Gayathri

Read only

0 Likes
1,119

Hi Gayathri,

ThankQ...this FM solved my prob....

Read only

Former Member
0 Likes
1,119

Hi,

If you defined that variable as INTEGER it will take care of that rounding.

Thanks.

Read only

Former Member
0 Likes
1,119

Hi,

Check out function module J_1I6_ROUND_TO_NEAREST_AMT

other wise you can also use ROUND(amount) or CEIL(amount).

Thanks & Regards

Read only

0 Likes
1,119

just move this to a type i variable, the system will automatically round it

data: a(16) type p decimals 2 .

data: b type i .

a = '16.49' .

b = a .

now b will have 17 as value

Regards

Raja

Read only

Former Member
0 Likes
1,119

Try this sample code

Data: w_a type i,
      w_b type i.

w_a = '10.67'.

CALL FUNCTION 'ROUND'
  EXPORTING
    input               = w_a
 IMPORTING
   OUTPUT              = w_b .

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

write:/ w_b.

This will work.

Kindly reward points and close the thread if ur problem got solved.

Read only

Former Member
0 Likes
1,119

CHK THIS

CALL FUNCTION 'HR_IN_ROUND_AMT'

EXPORTING

AMOUNT = val1

RNDOFF = '100'

RNDLMT = 'N'

IMPORTING

RETAMT = val2.

U CAN SET UR ROUNDING CHARACTERISTIC IN THE PARAMTER RNDOFF.

hOPE IT HELPS,

Regards,

Bikash