你好,有没有办法把它放在一个声明中?
DELETE e_worklist where wbs_element = '00000000000000000054TTO'.
DELETE e_worklist where wbs_element = '00000000000000000056TTO'.
DELETE e_worklist where wbs_element = '00000000000000000055TTO'.
DELETE e_worklist where wbs_element = '00000000000000000261TTO'.
DELETE e_worklist where wbs_element = '00000000000000000263TTO'.
DELETE e_worklist where wbs_element = '00000000000000000262TTO'.
答案 0 :(得分:2)
以上提出的IN
答案仅对数据库表有效:
删除 FROM e_worklist,其中wbs_element为IN (' 00000000000000000054TTO',' 00000000000000000056TTO',' 00000000000000000055TTO')。
在您的示例中,您放置了内部表语句,对于它们,建议的IN
语法对于文字无效。它有效only with selection tables/ranges,也需要populated properly。所以你不能将文字包装成IN
子句,你需要像这样做:
ws_wbs-sign = 'I'.
ws_wbs-option = 'EQ'.
ws_wbs-low = '00000000000000000054TTO'.
APPEND ws_wbs TO rt_wbs.
DELETE e_worklist WHERE wbs_element IN rt_wbs.
确实很麻烦,并且不会给你带来简洁。
然而,由于你的模式是单调的,你可以带上你的幻想并使用正则表达式,例如:
DELETE e_worklist WHERE wbs_element CP '00000000000000000*TTO'.
答案 1 :(得分:1)
请给你另一个提示。如果没有任何范围表,您还可以使用FILTER
和EXCEPT
获得更好的声明。文档为here。
您必须将e_worklist
复制或制作为sorted table
。
data:
ls_worklist like line of e_worklist,
****Ajust your key if necessary
lts_worklist like sorted table of ls_worklist with unique key table_line,
lth_wbs_element like hashed table of ls_worklist-wbs_element with unique key table_line.
lts_worklist = e_worklist.
****Add your other values if necessary
lth_wbs_element = value #( ( |00000000000000000054TTO| ) ( |00000000000000000263TTO| ) ).
e_worklist = filter #( lts_worklist except in lth_wbs_element where wbs_element = table_line ).
答案 2 :(得分:0)
由于它是一个内部表,与数据库命令不同,因为删除DELETE命令的数量没有真正的性能影响。您可以使用以下内容使其更简洁:
DELETE e_worklist where wbs_element =: '00000000000000000054TTO',
'00000000000000000056TTO',
'00000000000000000055TTO',
'00000000000000000261TTO',
'00000000000000000263TTO',
'00000000000000000262TTO'.