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 off

Former Member
0 Likes
701

Hi,

i am using a dec field(6,2)

I need to round of this field,how to do this..I am in 4.6c version..

Can any one give a sample

Ids there any function module

1 ACCEPTED SOLUTION
Read only

prasanth_kasturi
Active Contributor
0 Likes
680

Hi,

How do you want the O/P to be??? give an example plz

you can use the write statemnt addition : decimals and round

or use the FM ROUND

regards

prasanth

Hi,

How do you want the O/P to be??? give an example plz

you can use the write statemnt addition : decimals and round

or use the FM ROUND

regards

prasanth

5 REPLIES 5
Read only

prasanth_kasturi
Active Contributor
0 Likes
681

Hi,

How do you want the O/P to be??? give an example plz

you can use the write statemnt addition : decimals and round

or use the FM ROUND

regards

prasanth

Read only

GauthamV
Active Contributor
0 Likes
680

hi,

use arthimetic operations

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

TRUNC

Interger part of x

FRAC

Decimal part of x .

Read only

Former Member
0 Likes
680
Read only

Former Member
0 Likes
680

Use

CALL FUNCTION 'ROUND'
    EXPORTING
      DECIMALS      = 0
      INPUT         = P_QUOTA_ROUND
      SIGN          = '-'
    IMPORTING
      OUTPUT        = P_QUOTA_ROUND
    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.

Amit.

Read only

Subhankar
Active Contributor
0 Likes
680

Hi

Please do it like this way

DATA : v_data TYPE p LENGTH 6 DECIMALS 2,

l_str TYPE string,

l_str1 TYPE string,

l_str2 TYPE string.

v_data = '333.53' .

l_str = v_data.

SPLIT l_str at '.' INTO l_str1 l_str2.

if l_str2 >= '50'.

l_str1 = l_str1 + 1.

ENDIF.

move l_str1 to v_data.

WRITE : / v_data.