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 up a variable

Former Member
0 Likes
626

Hi All,

Is there any function module or any way to round up a variable.

For ex: 0.8 should become 1

and 0.3 should become 0.

Thanks.

5 REPLIES 5
Read only

Former Member
0 Likes
597

Hi,

parameters: v1(10) type c,

v2(10) type c.

data: v3 type p,

v4 type p.

v3 = v1.

v4 = v2.

WRITE:/ v3, v4.

or

you can use ceil and floor functions.

I think it is useful for you.

Read only

Former Member
0 Likes
597

Hi,

Search function ROUNDING

Cheers.

...Reward if useful.

Read only

Former Member
0 Likes
597

HI,

Check ROUND FM ....


DATA : V_VAL TYPE P DECIMALS 2 VALUE '5.6',
       V_VAL2 TYPE P DECIMALS 0.


CALL FUNCTION 'ROUND'
  EXPORTING
   DECIMALS            = 0
    INPUT               = V_VAL
*   SIGN                = ' '
 IMPORTING
   OUTPUT              = V_VAL2
* EXCEPTIONS
*   INPUT_INVALID       = 1
*   OVERFLOW            = 2
*   TYPE_INVALID        = 3
*   OTHERS              = 4
          .
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 : V_VAL2. 

Read only

Former Member
0 Likes
597
Read only

Former Member
0 Likes
597

Hi,

Use the function module

TB_NUMBER_ROUND.

Regards,

Raj.