判断是否为数值的几种方法

方法1 CATS_NUMERIC_INPUT_CHECK

方法2: NUMERIC_CHECK

方法3: 用catch命令自己做

 data  c(10type 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.

 

请使用浏览器的分享功能分享到微信等