两个函数同时用是,注意字段类型,P和C,用错,程序会DUMP!!!
"四舍五入
DATA : DAT TYPE P DECIMALS 9 VALUE '12.5445' ,
DAT1 TYPE P DECIMALS 2 .
* MOVE DAT TO DAT1.
CALL FUNCTION 'HR_NZ_ROUNDING_DECIMALS'
EXPORTING
VALUE_IN = DAT " Input field with decimals
CONV_DEC = 2 " i Number of desired decimals for conversion
IMPORTING
VALUE_OUT = DAT1. " Output field with rounded decimals
write : dat1.
"百分数
DATA : LV_DATA TYPE DMBTR .
DATA : LV_RESULT TYPE P DECIMALS 2,
LV_OUT(10) TYPE C.
LV_DATA = 3200.
LV_RESULT = LV_DATA / 5000 * 100.
WRITE : / LV_RESULT.
LV_OUT = |{ LV_RESULT }%|.
WRITE : / LV_OUT.