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

Round value...

Former Member
0 Likes
437

Dear all,

I want function module for round value.if anything related pls tel me.

Regards

Arul.s

3 REPLIES 3
Read only

Former Member
0 Likes
423

Check 'ROUND' FM.

data: num(10) type p decimals 4.

data: num1(5) type p decimals 2.

num = '4.023'.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 2

INPUT = num

  • SIGN = ' '

IMPORTING

OUTPUT = num1

  • EXCEPTIONS

  • NPUT_INVALID = 1

  • OVERFLOW = 2

*TYPE_INVALID = 3

  • OTHERS = 4

reward if useful...

balaji

Read only

Former Member
0 Likes
423

Hi,

declare a variable of type p decimals(req no)...

move the dobj u want to round off into it...

move it again to the original var..........

It gets rounded of automatically.

  DATA: var1 type char15,
        var2 type p DECIMALS 2.
  
  var1 = '23450.29874569'.
  write   var1.
  var2 = var1.
  var1 = var2.
  write / var1.

Cheers,

jose.

Read only

Former Member
0 Likes
423

Hi,

DATA N TYPE P DECIMALS 2.

DATA M TYPE P DECIMALS 2 VALUE '5.55',

DATA v_temp TYPE I .

N = FRAC( M ).

IF N > 0.5

v_temp = FLOOR( M ). WRITE: / 'FLOOR:', v_temp.

ELSE.

v_temp = CEIL( M ). WRITE: / 'CEIL: ', v_temp.

ENDIF.