SAP ABAP 删除前导0后缀0的几种方法

2023-10-12 18:24:42 浏览数 (3)

1.通过移位删除前导0或后缀0.

代码语言:javascript复制
data:
   str type char10 value '0010000000'.
shift str left deleting leading '0'.
shift str right deleting trailing '0'.

2.通过内外书式去除前导0.

如:

功能模块'CONVERSION_EXIT_ALPHA_OUTPUT'.

3.通过数值变量转换也可以去除前导0.

代码语言:javascript复制
data:
   int type i,
   str type char10 value '0010000000'.
 int = str.
 str = int.

   DATA CV_INT TYPE INT4.
   DATA CV_STR TYPE STRING.
   CV_INT = '199.00666'.
   CV_STR = CV_INT.
  CONDENSE CV_STR."BREAK-POINT.
   SHIFT CV_STR RIGHT DELETING TRAILING '0'.
   CONDENSE CV_STR.
   SHIFT CV_STR RIGHT DELETING TRAILING '.'.
   CONDENSE CV_STR.
  WRITE : CV_STR.

0 人点赞