HI,
Check 'ROUND' FM.
data: nu(10) type p decimals 4. data: nu1(5) type p decimals 2. nu = '4.017'. CALL FUNCTION 'ROUND' EXPORTING DECIMALS = 2 INPUT = nu * SIGN = ' ' IMPORTING OUTPUT = nu1 * EXCEPTIONS * NPUT_INVALID = 1 * OVERFLOW = 2 *TYPE_INVALID = 3 * OTHERS = 4
Regards,
Santosh
Hi,
Declare that Final variable as packed decimal(P)
data: total type p.
regards,
ravi shankar reddy
hi,
HR_ROUND_NUMBER – Rounds a number according to rules
ROUND – Rounds value to a number of decimal places
ROUND_AMOUNT – Rounding based on company and currency
UNIT_CONVERSION_SIMPLE – Converts measurement unit values and rounds
Hope this is helpful, Do reward.
data: a type p value '100.235' decimals 3,
b type p decimals 2.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = '3'
input = a
SIGN = ' '
IMPORTING
OUTPUT = b
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: a , b.
ans 100.235, 100.24
Add a comment