Skip to Content
avatar image
Former Member

For all entries - not giving duplictaes

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 10, 2009 at 12:19 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2009 at 10:49 AM

    HI,

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

    Regards,

    Nagaraj

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2009 at 10:52 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2009 at 10:55 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2009 at 12:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 10, 2009 at 12:58 PM

    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...

    Add comment
    10|10000 characters needed characters exceeded