Original post address: http://jiahongguang12.blog.163.com/blog/static/334665720071060551591/
The input parameter is 12.5445, so the FM is carried from the last decimal point. The FM parameter conv_dec = 2 is accurate to 2nd decimal places,
Printed result: 12.55;
Report z_test_007.
Data: DAT type P decimals 9 value '12. 5445 ',
Dat1 type P decimals 9.
* 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
* Exceptions
* No_rounding_required = 1 "No rounding required. (conv_dec> value_in dec)
* Decimals_greater_than_10 = 2 "conversion only possible with decimals <= 10
* Rounding_error = 3 "An error occurred during the decimal conversion
* Others = 4.
" HR_NZ_ROUNDING_DECIMALS
Write dat1.
Note: the processed data must be numeric. SAP is rounded to the nearest integer by default. If it is p type, you can define decimal places to limit it.