首页 > Linux操作系统 > Linux操作系统 > 判断是否为数值的几种方法
方法1: CATS_NUMERIC_INPUT_CHECK
方法2: NUMERIC_CHECK
方法3: 用catch命令自己做
data c(10) type c.
data i type p.
c = '123X'.
catch system-exceptions convt_no_number = 1.
i = c.
endcatch.
if sy-subrc = 1.
write:/ 'not number'.
else.
write:/ 'number'.
endif.
---------------------------------------------------------------------------------------
parameters:
p_char(5) type c.
end-of-selection.
data:
lv_int type i.
catch SYSTEM-EXCEPTIONS
convt_no_number = 1.
lv_int = p_char.
endcatch.
if sy-subrc = 0.
write: 'It is a number.', /.
else.
write: 'It is not a number.', /.
endif.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/166523/viewspace-425641/ ,如需转载,请注明出处,否则将追究法律责任。