ABAP 数值四舍五入函数
DATA : dat TYPE p DECIMALS 9 VALUE '12.5445' , dat1 TYPE p DECIMALS 9 . DATA dat2 TYPE p DECIMALS 9 VALUE '12.540'. * 方法一 CALL FUNCTION 'HR_NZ_ROUNDING_DECIMALS' EXPORTING value_in = dat conv_dec = 2 " 设置保留几位小数 IMPORTING value_out = dat1 EXCEPTIONS no_rounding_required = 1 decimals_greater_than_10 = 2 rounding_error = 3 OTHERS = 4. * 方法二 CALL FUNCTION 'ROUND' EXPORTING decimals = 0 " 保留多少位小数 input = dat2 sign = '+' " + 向上取舍 - 向下取舍 (负数也一样) IMPORTING output = dat1 " 输出返回结果 EXCEPTIONS input_invalid = 1 overflow = 2 type_invalid = 3 OTHERS = 4.