[英]Difference between both Translate elements in ABAP
I don´t get it, what´s the difference between both elements in ABAP:我不明白,ABAP 中的两个元素有什么区别:
The old TRANSLATE element:旧的 TRANSLATE 元素:
TRANSLATE l_value USING '" '.
The new translate element:新的翻译元素:
l_value = translate( val = l_value from = '"' to = ' ' )
or
l_value = translate( val = l_value from = '"' to = space )
The old element works fine.旧元素工作正常。 The character is replaced by a space.该字符由空格替换。
But the new one doesn't set a space, it´s shifting the text to left.但是新的没有设置空格,它将文本向左移动。
I don´t get it.. Do I do something wrong?我不明白..我做错了什么吗?
Another question:另一个问题:
I´m using the same code to replace cl_abap_char_utilities=>horizontal_tab
to SPACE
.我正在使用相同的代码将cl_abap_char_utilities=>horizontal_tab
替换为SPACE
。
But how can I replace horizontal_tabs
with the old translate
element?但是如何用旧的translate
元素替换horizontal_tabs
ntal_tabs 呢?
It's mentioned in the documentation of the translate function:在翻译 function 的文档中提到:
from and to are character-like expression positions. from和to是类似字符的表达式位置。 If they have a fixed length, trailing blanks are ignored.如果它们具有固定长度,则忽略尾随空格。
If you want to replace it with space, use a text string literal instead of a text field literal (see docu ).如果您想用空格替换它,请使用文本字符串文字而不是文本字段文字(请参阅文档)。
l_value = translate( val = l_value from = '"' to ` ` ).
For you second question, to use the old TRANSLATE just concatenate the required values and pass the variable to USING or use String Templates .对于第二个问题,要使用旧的TRANSLATE只需连接所需的值并将变量传递给USING或使用String Templates 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.