删除相邻重复项删除订单吗?

发布于 2024-12-10 22:05:21 字数 141 浏览 0 评论 0原文

如果存在具有相同密钥的条目。

按键对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

潜移默化 2024-12-17 22:05:21

来自 F1 帮助“删除相邻重复项”

在多条双线连续的情况下,所有
行 - 除了第一行 - 被删除。

所以第二行(相同的)应该删除

问候,

From F1 help on "delete adjacent duplicate"

In the case of several double lines following one another, all the
lines - except for the first - are deleted.

So the second (identical) line should be deleted

Regards,

月下客 2024-12-17 22:05:21

您可以考虑将另一个内部表声明为相同类型的排序表,而不是对标准表进行排序,具有与您要比较的字段相对应的唯一键,以消除重复项。它速度更快,允许您保持原始表不变,并且在我看来,使您的代码更具可读性,因为更容易理解哪些行被保留,哪些行不被保留。例子:

LOOP AT itab ASSIGNING <itab_row>.
  INSERT <itab_row> INTO TABLE sorted_itab.
ENDLOOP.

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:

LOOP AT itab ASSIGNING <itab_row>.
  INSERT <itab_row> INTO TABLE sorted_itab.
ENDLOOP.
蹲墙角沉默 2024-12-17 22:05:21

如果 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文