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 up decimal value

Former Member
0 Likes
16,938

Hi Guru,

Good day.

I have 5 output as bellow:


  .15       2.2     1 .4       14.8    .43

I need to show them like bellow:


   1        3        2          15         1

how can i get the desired output.

please help me.

With thanks

Moshiur

Moderator Message: Very basic question. Could be answered with a simple search and/or a few lines of code.

Edited by: kishan P on Sep 18, 2010 4:05 PM

1 ACCEPTED SOLUTION
Read only

Former Member
8,381

Hi moshiur sohel,

Use FM 'ROUND' to round any value. Your scenario is of Positive rounding, for that give SIGN parameter as '+'.The following is the example code.


PARAMETER P_VAL TYPE P DECIMALS 2.

CALL FUNCTION 'ROUND'
  EXPORTING
*   DECIMALS            = 0
    INPUT               = P_VAL
   SIGN                = '+'
 IMPORTING
   OUTPUT              = P_VAL
 EXCEPTIONS
   INPUT_INVALID       = 1
   OVERFLOW            = 2
   TYPE_INVALID        = 3
   OTHERS              = 4

Close the thread if you have solved your query.

Thanks & Regards,

Rock.

Hi Guru,

Good day.

I have 5 output as bellow:


  .15       2.2     1 .4       14.8    .43

I need to show them like bellow:


   1        3        2          15         1

how can i get the desired output.

please help me.

With thanks

Moshiur

Moderator Message: Very basic question. Could be answered with a simple search and/or a few lines of code.

Edited by: kishan P on Sep 18, 2010 4:05 PM

4 REPLIES 4
Read only

Former Member
0 Likes
8,381

Hi Moshiur,

Hope this may give you some idea to build your own logic...


DATA : w_sub type p DECIMALS 2 VALUE '2.4',
      w_num2 TYPE char10,
      w_num1 TYPE char10 ,
      w_char TYPE char10.

w_char = w_sub.
SPLIT w_char at '.' INTO w_num1 w_num2.

IF w_num2 > 0.
w_num1 = w_num1 + 1.
ENDIF.

WRITE w_num1.                      -- o/p is 3

Regards,

Aby

Read only

syed_ibrahim5
Active Participant
0 Likes
8,381

hi,

you can check this one out..


data : ad type p decimals 3. "your original input
data : ad1 type i."to convert to whole number
ad = '3.2'.
ad1 = ad.
if ad1 < ad.
  ad1 = ad1 + 1.
  endif.
write : ad1.

regards,

syed

Read only

Former Member
8,382

Hi moshiur sohel,

Use FM 'ROUND' to round any value. Your scenario is of Positive rounding, for that give SIGN parameter as '+'.The following is the example code.


PARAMETER P_VAL TYPE P DECIMALS 2.

CALL FUNCTION 'ROUND'
  EXPORTING
*   DECIMALS            = 0
    INPUT               = P_VAL
   SIGN                = '+'
 IMPORTING
   OUTPUT              = P_VAL
 EXCEPTIONS
   INPUT_INVALID       = 1
   OVERFLOW            = 2
   TYPE_INVALID        = 3
   OTHERS              = 4

Close the thread if you have solved your query.

Thanks & Regards,

Rock.

Read only

0 Likes
8,381

It's is useful but it only can be generated under program and not SE37