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

Former Member
0 Kudos

Hi Gurus,

Is there any aditions to SELECT FOR ALL ENTRIES Query which would accept Duplicate Entries also?

Thanks & Regards,

Vijaya.

9 REPLIES 9

Former Member
0 Kudos

When selecting records from a table using FOR ALL ENTRIES then select all the primary keys along with other required field to get all the records from the table.

Former Member
0 Kudos

Hello,

If you want to select all the entries in the table just use the field in your WHERE clause in SELECT query.

Thanks,

Jayant

Former Member
0 Kudos

nothing needs to be added to accept duplicates in for all entries in itab.

But you shouldnt have duplicate entries in for all entries itab as it will affect your performance. Just for performance we delete dupilcate entries.

former_member156446
Active Contributor
0 Kudos

generally before going to For all entries of table, delete adgescent duplicates in table will be done and then used in Select statement.

For you case you need not do that.. and you can use the table as it is.

Former Member
0 Kudos

Hi

What do you mean?

It's not possible there are duplicate records in a table: it would mean records with the same key.

If you means records having same value for certains fields u should use only that fields in the query and then check the record duplicate in the internal table

.DATA: WA LIKE ITAB,
          NEXT TYPE I.

SELECT * FROM <TABLE>
   FOR ALL ENTRIES ITAB WHERE FIELD1 = ITAB-FIELD1
                                              AND FIELD2 = ITAB-FIELD2
                                              AND FIELD3 = ITAB-FIELD3.

SORT ITAB BY FIELD1 FIELD2 FIELD3.

LOOP AT ITAB.
   NEXT = SY-TABIX + 1.
   READ TABLE ITAB INTO WA INDEX NEXT.
   
  IF ITAB-FIELD1 <> WA-FIELD1 OR
     ITAB-FIELD2 <> WA-FIELD2  OR
      ITAB-FIELD3 <> WA-FIELD3.
    DELETE ITAB.
  ENDIF.
ENDLOOP.

Max

Former Member
0 Kudos

Hi Gurus,

Thanks for your prompt replies,

here in my case i need duplicate entries also where i need to sum up all the entries,

when i use for all entries it is omiting the duplicate entries,

say

3

2

3

-


8( required o/p)

-


3

2

-


5( present o/p)

-


i have used all the key fields,hope you understand my req.

Thanks & Regards,

Vijaya.

0 Kudos

don't you select with DISTINCT addition? if yes remove it, otherwise copy you SELECT statement here for further analysis...

0 Kudos

You say that you have used all key fields then how can you expect duplicate values .

Former Member
0 Kudos

Hi Gurus,

Problem was solved,wrong with my code,

only solution is we have to use all key

fields.