欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

abap 如何去掉字符串前导0

发布时间:2025/3/20 编程问答 29 豆豆
生活随笔 收集整理的这篇文章主要介绍了 abap 如何去掉字符串前导0 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
SHIFT str LEFT DELETING LEADING '0'.
如果要在layout显示不出前面的0 格式:  &字段(zc)&
如果要在layout显示不出小数点后面的0 格式:   &字段(.0)&

关于shift
1.Shift a structure by a given number of postions
SHIFT <c> [BY <n> PLACES] [<mode>].
This statement shifts the field <c> by <n> positions. If you omit BY <n> PLACES, <n> is
interpreted as one. If <n> is 0 or negative, <c> remains unchanged. If <n> exceeds the length
<c>, <c> is padded with blanks. <n> can be variable.
With the different (<mode>) options, you can shift the field <c> in the following ways:
· LEFT:
Shift <n> positions to the left and pad with <n> blanks on the right (default setting).
· RIGHT:
Shift <n> positions to the right and pad with <n> spaces on the left.
· CIRCULAR:
Shift <n> positions to the left so that <n> characters on the left appear on the right.

2.Shift a structure up to a given string
To shift field contents up to a given string, use the SHIFT statement as follows
Syntax
SHIFT <c> UP TO <str> <mode>.
ABAP searches the field contents of <c> until it finds the string <str> and shifts the field <c> up to
the field margin. The (<mode>) options are the same as described in the section Shifting a
Structure by a Given Number of Positions [Page 201]. <str> can be a variable.
If <str> is not found in <c>, SY-SUBRC is set to 4 and <c> is not shifted. Otherwise, SY-SUBRC is set to 0.
3.Shifting a structure according to the first or last character
You can use the SHIFT statement to shift a field to the left or to the right, provided the first or last
character satisfies a certain condition. To do this, use the following
syntax:
SHIFT <c> LEFT DELETING LEADING <str>.
SHIFT <c> RIGHT DELETING TRAILING <str>.

总结

以上是生活随笔为你收集整理的abap 如何去掉字符串前导0的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。