09-10-2008 8:29 AM
HI All,
Suppose a number is like this 3.25
I need to round the number to 4.
Pls tell me how to make it.
Thanks and regards,
shake sha vali
09-10-2008 8:40 AM
hi,
Either use function module " Round ".
data input type p decimals 2 value '12.11'.
data output type p decimals 2.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2
input = input
SIGN = '+'
IMPORTING
OUTPUT = output
* 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.
write: output.
Or
use CIEL(3.25).
i.e.
data: n1 TYPE p decimals 2 value '3.25',
n2 type i.
n2 = CEIL( n1 ).
write: n2.
n2 = 4.
thanx.
09-10-2008 8:30 AM
09-10-2008 8:37 AM
hii
use like below code
DATA val1 TYPE P DECIMALS 2.
DATA val3 TYPE P DECIMALS 2.
DATA val2 TYPE P DECIMALS 2 VALUE '3.24'.
DATA val type p decimals 2 value '0.5'.
val3 = FRAC( val2 ).
if val3 > val .
val1 = floor( val2 ).
else.
val1 = ceil( val2 ).
endif.
write:/ val1.
write:/ val2.
regards
twinkal
09-10-2008 8:38 AM
It is coming after calculation or it is a static value
Regards,
Rajneesh Gupta
09-10-2008 8:40 AM
hi,
Either use function module " Round ".
data input type p decimals 2 value '12.11'.
data output type p decimals 2.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 2
input = input
SIGN = '+'
IMPORTING
OUTPUT = output
* 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.
write: output.
Or
use CIEL(3.25).
i.e.
data: n1 TYPE p decimals 2 value '3.25',
n2 type i.
n2 = CEIL( n1 ).
write: n2.
n2 = 4.
thanx.
09-10-2008 8:44 AM