判断字符串是数字还是汉字还是英文

(1)判断字符串是英文还是汉字

DATA: c1 TYPE char1,
vislen TYPE i.
c1 = '好'.
CALL FUNCTION 'NLS_VISUAL_CHARLEN'
EXPORTING
str = c1
IMPORTING
len_visual = vislen.

IF vislen = 1.
WRITE: '英文'.
ELSE.
WRITE: '汉字'.
ENDIF.

 

 

(2)判断字符串是否为数字

DATA:bb TYPE i.

DATA as_str TYPE string.
as_str = '0.005'.

CATCH SYSTEM-EXCEPTIONS conversion_errors = 1. "判断字符串as_str中是否含有数字,if sy-subrc = 0 ,说明有数字
MOVE as_str TO bb.
ENDCATCH.
IF sy-subrc = 0 .
WRITE '这是个数字'.
ELSE.
WRITE '这不是数字'.
ENDIF.

posted @ 2019-10-24 15:47  纱缚之印  阅读(1398)  评论(0编辑  收藏  举报