很简单,直接上代码:
REPORT ZLM_SISHEWURU.
DATA lv_input TYPE p DECIMALS 2 VALUE '12.45'.
DATA lv_output TYPE p DECIMALS 2.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 0 " 保留多少位小数
input = lv_input
sign = 'X' " X 四舍五入 向上取舍 - 向下取舍 (负数也一样)
IMPORTING
output = lv_output " 输出返回结果
EXCEPTIONS
input_invalid = 1
overflow = 2
type_invalid = 3
OTHERS = 4.
WRITE: /'四舍五入'.
WRITE: / 'lv_input:' , lv_input, ' -> ', lv_output .
"另外,直接用 P类型接收,本身就是四舍五入
DATA: lv_dec0 TYPE p DECIMALS 0.
DATA: lv_dec1 TYPE p DECIMALS 1.
lv_dec0 = lv_input.
WRITE: / 'lv_dec0:', lv_input, ' -> ', lv_dec0 .
lv_dec1 = lv_input.
WRITE: / 'lv_dec1:', lv_input, ' -> ', lv_dec1 .
最近实在是太忙了,没时间整理文档,实在不好意思~