Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

For all entries deleting duplicates

Former Member
0 Kudos

Hi Guys,

Quick question, I have an internal table where fields are F1, F2, F3, F4, none of them are key fields. If I use this internal table in a FOR ALL ENTRIES statement and in the WHERE condition I use F1 and F2, does this automatically delete duplicates comparing F1 and F2 in ABAP? Or are there no duplicate entries deleted? Would it help the SQL statement if I delete adjacent entries comparing F1 and F2 programatically in ABAP?

Thanks,

Jack

4 REPLIES 4

SilvioMiranda
Participant
0 Kudos

Acording to help in ABAP Keyword Documentation :

Notes

  • The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.
  • The same internal table can be specified after FOR ALL ENTRIES and after INTO. The content of the table is evaluated by FOR ALL ENTRIES and then overwritten by the INTO clause.
  • With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as when the addition DISTINCT is specified in the definition of the selection set. Unlike DISTINCT, the rows are not always deleted from the database system but instead are sometimes first deleted from the result set on the application server. The duplicate rows are then removed from the database system if the SELECT statement can be passed to the database system as a single SQL statement. If the SELECT statement has to be distributed to multiple SQL statements, the aggregation takes place on the application server.



The duplicated entries are deleted in for all entries...


Regards..

ŁukaszPęgiel
Contributor
0 Kudos

If you decided to go with FAE not with join then it's better for select statement to deleted duplicates before passing table to select. Also sort the table by the key used in where clause and use hints if possible (in case of oracle for example) to lower the number of generated selects.

Juwin
Active Contributor
0 Kudos

This is standard behavior. To avoid this from happening, you need to select all the key fields from the table, when you use FAE in the select statement.

Thanks,

Juwin

Former Member
0 Kudos

Hi Jack,

Even I faced similar issue recently.

When we use FOR ALL ENTRIES, the result set of records will be unique.

Example if we have two records in table 1 2 3 4 and 1 2 3 4, our internal table will have only 1 2 3 4.

If any single field of the result varies the record will be retained in the internal table.

Hence it is always suggested to fetch the Key Fields in the result set while using FAE.

Thanks and Regards,

Vinay Mutt