判断字段是否为数字(Determine whether the field is a number)

其他功能需要有个金额字段不得不是CHAR类型,但CHAR类型还是可以存储字符,所以需要对金额字段添加判断。

1.首先参考函数NUMERIC_CHECK,但金额存在小数位,NUMERIC_CHECK方法在识别正数类型正常,但小数会识别为CHAR类型,无法满足需求

2.运用关键字CO,代码如下

DATA:str TYPE string VALUE ‘.0123456789’,

     str1 TYPE string.

      IF lv_zamount <> ”.        CLEAR str1.        str1 = lv_zamount .        IF NOT str1 CO str.          MESSAGE ‘*****金额请输入数字’ TYPE ‘S’ DISPLAY LIKE ‘E’.        ENDIF.      ENDIF.

————————

Other functions require an amount field, which must be char type, but char type can still store characters, so you need to add judgment to the amount field.

1. First, refer to the function numeric_ Check, but the amount has decimal places, numeric_ The check method is normal in identifying positive numbers, but decimals will be identified as char types, which cannot meet the requirements

2. Use the keyword CO and the code is as follows

DATA:str TYPE string VALUE ‘.0123456789’,

str1   TYPE   string.

IF   lv_ zamount <& gt;  ”.         CLEAR   str1.          str1  = lv_ zamount  .         IF   NOT   str1   CO   str.            MESSAGE  ‘***** Amount, please enter a number ‘   TYPE  ‘ S’   DISPLAY   LIKE  ‘ E’.          ENDIF.       ENDIF.