Former Member

Commercial rounding to the closest integer number

Hi,

I have a requirement to convert the Menge(quantity) to the nearest integer number by rounding off.

For example 21.490 becomes 21.000 while 21.510 becomes 22.000.

I checked for Floor, Ceil statements but these are not solving my purpose as they give next lowest or highest value.

I need to convert it as per my example. At run time it should check first place after decimal and then should convert it accordingly.

Swati

10|10000 characters needed characters exceeded

• Former Member
Feb 25, 2009 at 10:21 AM

Hi,

Try assigning your variable to below declared variable.

DATA: gv_var type p length 2 decimals 3.

Thanks,

Srilakshmi.

10|10000 characters needed characters exceeded
• Feb 25, 2009 at 10:20 AM

Use ROUND function module

10|10000 characters needed characters exceeded
• Former Member Former Member

Hi ,

we were facing the same problem while developing ABAP-HR reports

data:dec_part type p decimals 4,

num1 type PA0014-BETRG,

num2 TYPE PA0014-BETRG,

num TYPE string.

num = '21.490'.

break-point.

if num = '21.490'.

dec_part = frac( num ).

if dec_part >= '0.500'.

num1 = ceil( num ).

else.

num1 = FLOOR( num ).

endif.

endif.

num = '21.510'.

if num = '21.510'.

dec_part = frac( num ).

if dec_part >= '0.500'.

num2 = ceil( num ).

else.

num2 = FLOOR( num ).

endif.

endif.

• Former Member
Feb 25, 2009 at 12:39 PM

split number at '.' into lv_num1 lv_num2

if lv_num2 + 0(1) < = 4

concatenate lv_num1 '.' '000' into lv_num1.

else

lv_num1 = lv_num1 + 1.

concatenate lv_num1 '.' '000' into lv_num1.

Edited by: BrightSide on Feb 25, 2009 12:39 PM

10|10000 characters needed characters exceeded
• Dec 24, 2014 at 11:54 AM

Use function ROUND.

e.g. result = round( val = '21.490' dec = 0 )

10|10000 characters needed characters exceeded
• Dec 24, 2014 at 12:17 PM

Hi,

Do it on very simple way. ðŸ˜‰

Data: Int type I,

val type (your values data type ).

int = your values variable [21.490].

int = 21. [not require to write in code, just for information ]

val = int . [21.000 , final value].

Regards.

Praveer.