删除相邻重复项删除订单吗?
如果存在具有相同密钥的条目。
按键对 itab 进行排序。 从 itab 比较键中删除相邻的重复项。
有谁知道如果删除相邻的重复项..比较键会删除哪一个? 第一个还是第二个?
If there are entries with the same key.
sort itab by key.
delete adjacent duplicates from itab comparing key.
Does anyone know which one will be deleted if delete adjacent duplicates..comparing key?
The first one or second one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 F1 帮助“删除相邻重复项”
所以第二行(相同的)应该删除
问候,
From F1 help on "delete adjacent duplicate"
So the second (identical) line should be deleted
Regards,
您可以考虑将另一个内部表声明为相同类型的排序表,而不是对标准表进行排序,具有与您要比较的字段相对应的唯一键,以消除重复项。它速度更快,允许您保持原始表不变,并且在我看来,使您的代码更具可读性,因为更容易理解哪些行被保留,哪些行不被保留。例子:
Instead of sorting a standard table, you could consider declaring another internal table as a sorted table of the same type with a unique key corresponding to the fields you're comparing to eliminate the duplicates. It's faster, allows you to keep your original table unchanged, and, in my opinion, makes your code more readable because it's easier to understand which rows are kept and which ones are not. Example:
如果 itab 中的数据是从数据库中获取的,那么它比在 SELECT 中使用 ORDER BY 加法和使用删除相邻重复项要好。排序算法的成本为 nlog(n),并且 DBMS 执行此类操作而不是 ABAP 更好。
显然,如果您可以在 SQL 中执行 DISTINCT 或 GROUP BY,则可以避免同时使用 SORT 和删除相邻重复项,并且应该解决所有性能问题
If data in your itab are fetched from DB, it's better than you use ORDER BY addition in SELECT and than you can use the delete adjacent duplicates . Sorting algorithm costs nlog(n) and is better that DBMS does these type of operation instead ABAP.
Obviously that if you can do the DISTINCT or GROUP BY in SQL you avoid to use both SORT and delete adjacent duplicates and you should solve all performance problems