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

Logic to round off

Former Member
0 Likes
1,040

Hi Folks,

Can some please provide some logic to round of the values? I have one field p_temp of type P decimals 2. If it contain 1.24 it should round to 1, and if it contains 1.7 then it should round to 2. Simply it the decimal point is greater than .5 then it should round to the next value. And if it is less than .5 then it should round the current.

Please help me to put the dynamic logic.

Thanks,

Raghu.

Hi Folks,

Can some please provide some logic to round of the values? I have one field p_temp of type P decimals 2. If it contain 1.24 it should round to 1, and if it contains 1.7 then it should round to 2. Simply it the decimal point is greater than .5 then it should round to the next value. And if it is less than .5 then it should round the current.

Please help me to put the dynamic logic.

Thanks,

Raghu.

7 REPLIES 7
Read only

Sm1tje
Active Contributor
0 Likes
985

move it to an integer field (TYPE I).

Read only

Former Member
0 Likes
985

HI,

Declare one integer variable and pass this value to that integer then the value will automatically round.

Rgds,

Bujji

Read only

Former Member
0 Likes
985

Hi,

DATA: VAR1 TYPE P DECIMALS 2,

RES TYPE P DECIMALS 2.

VAR1 = '12.33'.

RES = ROUND( VAR1 ).

WRITE RES.

Also check the following Function modules

ROUND_AMOUNT

FI_ROUND_AMOUNT

FM HR_IN_ROUND_AMT

Regards,

Raj.

Read only

Former Member
0 Likes
985

hi,

Use ceil or floor command to convert ..

data : v_d(10) type p decimals 2.

v_d = '352.65'.

v_d = ceil( v_d ).

data : v_d1(10) type p decimals 2.

v_d1 = '352.25'.

v_d1 = floor( v_d1 ).

regards

siva

Read only

Former Member
0 Likes
985

Hi,

Check the below code :

data :  i_val type i.
parameters : p_dec type p decimals 2.

i_val = p_dec.

write : i_val.

NOTE : dont give 1.25 instead you can give 1,25. Instead of "." you need to use "," that depends on your user settings.

Regards,

Raghu

Read only

Former Member
0 Likes
985

hi

u can also use

CEIL( ) function.

Read only

Former Member
0 Likes
985

Hi Raghu,

U can use the FM 'ROUND'


CALL FUNCTION 'ROUND'
  EXPORTING
*   DECIMALS            = 0
    input               = v_data
*   SIGN                = ' '
 IMPORTING
   OUTPUT              = v_data
          .

thanks,

teja.