Former Member

# 1.232 to 1.24

Hi

if the value of a is 1.232 then i want 1.24

a = 1.23 i want 1.23

a = 1.236 i want 1.24

Thanks,

10|10000 characters needed characters exceeded

### Related questions

Posted on Dec 23, 2008 at 03:26 AM
```data : l_val type p decimals 2,
l_val2 type p decimals 3.

l_val2 = 1.236.
move l_val2 to l_val.

write :/ l_val.```

Best regards,

Prashant

10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 23, 2008 at 03:30 AM

hi,you can declare two variables like

data : v_val type p decimals 2,

v_val2 type p decimals 3.

and then assign values to v_val and then move it to value 2.

thanks

10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 23, 2008 at 03:47 AM

this not possible by using key word but you can do manupulations,

usevally round keyword will do if 0.126 -

> 0.13, 0.123----

> 0.12

10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 23, 2008 at 03:50 AM

Hi,

Declare on more variable with two decimal places & pass the value.

da: temp type p decimals 2.

Thanks,

Krishna..

10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 23, 2008 at 04:14 AM

Use FM ROUND

10|10000 characters needed characters exceeded
• Former Member

HI,

We have mathematical indicators in abap As Ceil, floor, truncate, round, etc this will be use full.

Regards,

Naresh

• Former Member
Posted on Dec 23, 2008 at 05:59 AM

Hi,

Use the following code:

```DATA: num1 TYPE p DECIMALS 3 VALUE '1.232',
num2 TYPE p DECIMALS 2.

CALL FUNCTION 'ROUND'
EXPORTING
decimals      = 2
input         = num1
sign          = '+'
IMPORTING
output        = num2
EXCEPTIONS
input_invalid = 1
overflow      = 2
type_invalid  = 3
OTHERS        = 4.

IF sy-subrc EQ 0.
WRITE:/ num1, num2.
ENDIF.```

This will work for all the cases:

num1 = 1.232 then num2 = 1.24

num1 = 1.23 then num2 = 1.23

num1 = 1.236 then num2 = 1.24

Regards,

Lavanya

Edited by: Lavanya Gourisetty on Dec 23, 2008 9:49 AM

Edited by: Lavanya Gourisetty on Dec 23, 2008 10:23 AM

10|10000 characters needed characters exceeded
• Former Member
Posted on Dec 23, 2008 at 10:11 AM

Hi,

Try like this:

WRITE A ROUND 2.

Regards,