一.知识点;
DELETE ADJACENT DUPLICATES FROM.
二.例子;
SORT gt_resb BY matnr.
DELETE ADJACENT DUPLICATES FROM gt_resb COMPARING matnr.
用之前
用之后
三. 总结;
1.保留的是第一行,后面重复的都删除。
2.不要用select distinct,会再数据系统中排序,因此会绕过SAP缓存,这样速度会慢,这个语法不建议使用,不能在大表中,可以在小表中。
3.能在内表中操作,一定要在内表中操作,不能在数据表中操作
4.一定要排序. 这样才能完全去除重复的行;
5. From sap official explation.
With these additions, the statement DELETE deletes all lines in certain groups of lines, except for the first line of the group. These are groups of lines that follow one another and have the same content in certain components. If the addition COMPARING is not specified, the groups are determined by the content of the key fields.
Lines are considered to be doubled if the content of neighboring lines is the same in the components examined. In the case of several double lines following one another, all the lines - except for the first - are deleted.