Skip to Content
author's profile photo Former Member
Former Member

About Duplicate entries

Hi experts,

In internal table i have many account numbers.

There are some duplicate entries. i have removed all the duplicates using the following code.

but i cannot remove all the duplicate entries.

certain scenarios i should have duplicate elements also in my output.

certain scenario i should remove the duplicates.

is there any way to remove few duplicate entries from internal table.

your furthur clarification i will send the code also.

DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

LOOP AT ITAB_temp.

LOOP AT ITAB WHERE RI_ACCT_NO = ITAB_TEMP-RI_ACCT_NO.

SUM_BETRH = SUM_BETRH + itab-BETRH.

SUM_BETRW = SUM_BETRW + itab-BETRW.

ENDLOOP.

ITAB_ALS = ITAB.

ITAB_ALS-BETRH = SUM_BETRH.

ITAB_ALS-BETRW = SUM_BETRW.

APPEND ITAB_ALS.

CLEAR: SUM_BETRH, SUM_BETRW, ITAB_ALS.

ENDLOOP.

if u know pls send me documents to

Jmailgarden@gmail.com

its very urgent.

Thank you in advance.

Jeyanthi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 11:58 AM

    well you gotta remove the duplicates you dont wish to have manually.

    Loop at itab into wa.

    IF *here check your conditions if this entry has to be removed or not.

    remove entry.

    ENDIF

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:00 PM

    before deleting duplicates entries are you sorting your internal table?????

    SORT itab_temp by RI_ACCT_NO.

    DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:02 PM

    Hi,

    Pls try to add the following code before,

    DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

    code:

    Sort itab_temp by RI_ACCT_NO .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:17 PM

    Hi,

    keep more than one conditions in your delete adjacent duplicates based on the requirement you have.

    This will delete the entries in itab based on the condition

    Regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 28, 2008 at 12:59 PM

    Hi

    You have add the following statement before the delete duplicate statement

    SORT itab_temp BY RI_ACCT_NO.

    DELETE ADJACENT DUPLICATES FROM itab_temp COMPARING RI_ACCT_NO .

    I think now it will work. Otherwise some problem internal table fields.

    Moreover this code not efficient. You are using nested loops, it is performance killer. Instead you can use for all entries. Already u have data in ITAB_TEMP.

    Select f1 f2... from XTABLE into table ITAB for all entries in ITAB_TEMP where RI_ACCT_NO = ITAB_TEMP-RI_ACCT_NO .

    then u can add addition logic by using one loop and endloop.

    Reward me if it is useful

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 28, 2008 at 01:13 PM

    Hi Jeyanthi,

    Your code is correct if you just put ' SORT itab_temp BY RI_ACCT_NO' statement before.

    If you wish, you can make your code better by using the COLLECT statement to sum up the values. This way you can avoid looping on to nested internal tables.

    Kind Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.