PP开发有时会遇到工时转换的情况,比如原先工时是按照小时计算的,现在要转换成按照秒计算,
这时可以用函数 UNIT_CONVERSION_SIMPLE进行转换:
例子代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
REPORT ztest_unit_convert. DATA:l_out TYPE p. CALL FUNCTION 'UNIT_CONVERSION_SIMPLE' EXPORTING input = 2 * NO_TYPE_CHECK = 'X' * ROUND_SIGN = ' ' unit_in = 'H' unit_out = 'S' IMPORTING * ADD_CONST = * DECIMALS = * DENOMINATOR = * NUMERATOR = output = l_out EXCEPTIONS conversion_not_found = 1 division_by_zero = 2 input_invalid = 3 output_invalid = 4 overflow = 5 type_invalid = 6 units_missing = 7 unit_in_not_found = 8 unit_out_not_found = 9 OTHERS = 10. IF sy-subrc = 0. * Implement suitable error handling here WRITE :l_out. ENDIF. |
输出:将2小时转换成7200秒
以上。
发表评论