用逗号连接字符串列表
Join list of strings with a comma
我正在学习 ABAP。过去我使用 python.
Python: ', '.join(['one', 'two', 'three'])
Result: 'one, two, three'
如何将字符串列表与 ,
连接起来并创建一个包含 one, two, three
的字符串?
系统版本为740
我在这里有点吐口水,但以下内容应该有效。
您得到了 table 个字符串 lt_strings
和一个输出变量 lv_concatenated
。 ABAP 有一个名为 concatenate 的内置命令,您可以输入 table。
data: lt_strings type string_table,
lv_concatenated type string.
concatenate lines of lt_strings into lv_concatenated separated by ','.
另一种写法CONCATENATE LINES OF ...
是使用7.40函数concat_lines_of( [table =] itab [sep = sep] )
cl_demo_output=>display( concat_lines_of(
table = value string_table( ( `one` ) ( `two` ) ( `three` ) )
sep = `, ` ) ).
(结果:'one, two, three')
我正在学习 ABAP。过去我使用 python.
Python: ', '.join(['one', 'two', 'three'])
Result: 'one, two, three'
如何将字符串列表与 ,
连接起来并创建一个包含 one, two, three
的字符串?
系统版本为740
我在这里有点吐口水,但以下内容应该有效。
您得到了 table 个字符串 lt_strings
和一个输出变量 lv_concatenated
。 ABAP 有一个名为 concatenate 的内置命令,您可以输入 table。
data: lt_strings type string_table,
lv_concatenated type string.
concatenate lines of lt_strings into lv_concatenated separated by ','.
另一种写法CONCATENATE LINES OF ...
是使用7.40函数concat_lines_of( [table =] itab [sep = sep] )
cl_demo_output=>display( concat_lines_of(
table = value string_table( ( `one` ) ( `two` ) ( `three` ) )
sep = `, ` ) ).
(结果:'one, two, three')