- 通过 function module 检查日期是否合法(DDUT_INPUT_CHECK的校验会根据账户的时间设置格式)
日期校验方式一:
1 CALL FUNCTION ‘DATE_CHECK_PLAUSIBILITY’ 2 EXPORTING 3 date = sy-datum 4 EXCEPTIONS 5 plausibility_check_failed = 1 6 OTHERS = 2. 7 CASE sy-subrc. 8 WHEN 0. 9 WRITE:’sucess’. 10 WHEN 1. 11 WRITE:’failed’. 12 WHEN OTHERS. 13 MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 14 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 15 ENDCASE.
View Code
日期校验方式二:
1 DATA: v_date TYPE d, 2 v_c(8) TYPE c. 3 **************************** 4 * check date 5 **************************** 6 v_c = '20140532'. 7 v_date = v_c. 8 IF v_date = 0. 9 WRITE: / v_c , ' is a Wrong date!'. 10 ELSE. 11 WRITE: / v_c , ' is a OK date.'. 12 ENDIF.
View Code
- DDUT_INPUT_CHECK校验数量时可能会出错(尤其是接受外围系统的传输 输入 1.0 P(10)3 会输出 1000.0 P(7)3)
数字校验方式一:
1 DATA: v_int TYPE i, 2 v_c(8) TYPE c. 3 **************************** 4 * check number 5 **************************** 6 v_c = '-123.123'. 7 TRY. 8 v_int = v_c. 9 WRITE: / v_c , ' is a OK number.'. 10 CATCH cx_root. "all error 11 WRITE: / v_c ,' is a Wrong number!'. 12 ENDTRY.
View Code
数字校验方式二:
1 DATA:l_htype LIKE dd01v-datatype. 2 CLEAR l_htype. 3 CALL FUNCTION 'NUMERIC_CHECK' 4 EXPORTING 5 string_in = '123456789 ' 6 IMPORTING 7 * STRING_OUT = 8 htype = l_htype. 9 WRITE:l_htype."输出NUMC
View Code
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18382.html