‎2006 Dec 16 7:44 AM
Hi freinds,plz tell me what are the values to be pass to the function round. suppose i want to round off 56.4456 to only 2 decimals, what value should i pass in,DECIMALS,INPUT,SIGN.
‎2006 Dec 16 8:32 AM
hi,
no need fro any FM.
check this sample code.
data: a(16) type p decimals 4 .
data: b(16) type p decimals 2 .
data: c(30) .
a = '56.4456'.
write:/ a .
move: a to b .
write:/ b .
write a to c decimals 2 .
write:/ c .
the results will be
a = 56.4456
b = 56.44
c = 56.44you can see automatic rounding of happenning as well
Regards
Anver
‎2006 Dec 16 8:10 AM
execute the code .
u need to work this out like this.
tricky part is if u want to see this in the fm input will be character of 200 length .
so u will get an error as the fm will take data types P or F or I and not char .
DATA:
L_MENGE_P5(16) TYPE P DECIMALS 5,
L_MENGE_P3(16) TYPE P DECIMALS 3,
L_ANDEC like T006-ANDEC value 2.
L_MENGE_P5 = '56.4456'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = L_ANDEC
input = L_MENGE_P5 "over here u need to pass other than char
SIGN = '+'
IMPORTING
OUTPUT = L_MENGE_P3
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:/ L_MENGE_P3.hope this helps ,
regards,
vijay
‎2006 Dec 16 8:32 AM
hi,
no need fro any FM.
check this sample code.
data: a(16) type p decimals 4 .
data: b(16) type p decimals 2 .
data: c(30) .
a = '56.4456'.
write:/ a .
move: a to b .
write:/ b .
write a to c decimals 2 .
write:/ c .
the results will be
a = 56.4456
b = 56.44
c = 56.44you can see automatic rounding of happenning as well
Regards
Anver