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 - not giving duplictaes

Former Member
0 Kudos

HI,

The for all entries is not retrieving duplicates.I need to include all selections.Any other way to do this other than including then select in loop or giving all pkeys....

Kind Rgards,

Shital

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I think you can do in one other way. Once you have obtained the records of the first table, collect all the field values which you will be requiring in ranges and then use this ranges to select from the 2nd table. i.e if you are using two fields of the 1st table in the where clause of the 2nd table, then collect all the values of these two fields in two range tables and then use it for selection from 2nd table.

Hope this will solve your issue.

Regards,

Susanta

7 REPLIES 7

former_member404244
Active Contributor
0 Kudos

HI,

For all entries won't give any duplicate entries.....Use inner join..

Regards,

Nagaraj

Former Member
0 Kudos

For all entries will only fetch details for distinct entries.

You have to put a loop at original internal table and use read to modify it with the fetched entries.

For example;

Select .....
into corresponding fields of table itab1
....
where....

Select ...
into  table itab2
for all entries in itab1
where field1 = itab1-field1....

Loop at itab1.
Read table itab2 where field1 = itab1-field1.
If sy-subrc = 0.
itab1-field5 = itab2-field2.
itab1-field6 = itab2-field3.
.........
........
Modify itab1.
endif.
endloop

Try like this, it will solve your problem.

Regards

Karthik D

Former Member
0 Kudos

hi,

Can you plese paste your code here ...Also do check in database first

For all entries checks records obtained in the first table and gives records based on your select statmenet's WHERE clause...

thanks

Former Member
0 Kudos

Hi,

I think you can do in one other way. Once you have obtained the records of the first table, collect all the field values which you will be requiring in ranges and then use this ranges to select from the 2nd table. i.e if you are using two fields of the 1st table in the where clause of the 2nd table, then collect all the values of these two fields in two range tables and then use it for selection from 2nd table.

Hope this will solve your issue.

Regards,

Susanta

Former Member
0 Kudos

one more solution is to include in your selection an additional field, so that the rows become distinct.

preferably, select all the primary keys in your select statement..

thanks,

bikash

Former Member
0 Kudos

If your original code is like this:

SELECT ...

... INTO TABLE2

FOR ALL ENTRIES IN TABLE1...

Use left outer join instead. The left table should be your current table2 and the right table should be your current table1. This should bring out duplicates...

SELECT ...

... FROM DBTAB2 LEFT OUTER JOIN DBTAB1...

0 Kudos

hi all,

thanks for your response!

I will try the solutions and get back to you.Cheers.

Shital