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

Delete duplicate entriess from the internal table its urgent pls help.

Hi friends,

Hope everybody is doing good,Here is m query on delete duplicate data from the intenal table.

I have an internal table which contain data in the following format.

Doc No Comp Cod Vendor Assignment

1500000009 JM11 00000000

1500000008 JM11 20070212(Repeating)

1500000007 JM11 20070212

1500000006 JM11 00000000

1500000005 JM11 00000000

1500000004 JM11 00000000(Repeating)

1500000003 JM11 00000000 (Repeating)

1500000002 JM11 00000000

1500000001 JM11 20050302

1500000000 JM11 00000000

1500000003 JM11 10000088

1500000001 JM11 10000088

1500000030 JM11 10006260

1500000010 JM11 10006269

1500000008 JM11 10006269

1500000006 JM11 10006269

1500000004 JM11 10006269

if you see the document numbers,there are some document number which are repeating here,there are some document numer which contain vendor number but not the assignments,some of the document numbers contain the assignments but not the vendors.

If my internal table contain this kind of data with repeted document numbers than i want the document number which contains only the vendor number.

Pls help me with the appropriate logic,its urgent.

Thanks a lot

mrutyun^

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 11, 2007 at 05:44 AM

    Hi,

    Try this:

    SORT IT_DATA BY Doc No Comp Cod Vendor Assignment.
    DELETE ADJACENT DUPLICATES FROM IT_DATA COMPARING ALL FIELDS.
    

    Regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 11, 2007 at 05:52 AM

    sort itab by Doc_No Comp_Cod Assignment ascending Vendor descending.

    delete adjacent-duplicates from itab comparing Doc_No Comp_Cod Vendor Assignment.

    reward if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 11, 2007 at 05:53 AM

    Hi,

    <u><b>Deleting Adjacent Duplicate Entries</b></u>

    To delete adjacent duplicate entries use the following statement:

    DELETE ADJACENT DUPLICATE ENTRIES FROM <itab>

    [COMPARING <f1> <f2> ...

    |ALL FIELDS].

    The system deletes all adjacent duplicate entries from the internal table <itab>. Entries are

    duplicate if they fulfill one of the following compare criteria:

    Without the COMPARING addition, the contents of the key fields of the table must be

    identical in both lines.

    If you use the addition COMPARING <f1> <f2> ... the contents of the specified fields <f1>

    <f2> ... must be identical in both lines. You can also specify a field <fi> dynamically as

    the contents of a field <ni> in the form (<ni>). If <ni> is empty when the statement is

    executed, it is ignored. You can restrict the search to partial fields by

    specifying offset and length.

    If you use the addition COMPARING ALL FIELDS the contents of all fields of both lines

    must be identical.

    You can use this statement to delete all duplicate entries from an internal table if the table is

    sorted by the specified compare criterion.

    If at least one line is deleted, the system sets SY-SUBRC to 0, otherwise to 4.

    Examples

    DATA: BEGIN OF LINE,

    COL1 TYPE I,

    COL2 TYPE I,

    END OF LINE.

    DATA ITAB LIKE HASHED TABLE OF LINE WITH UNIQUE KEY COL1.

    DO 4 TIMES.

    LINE-COL1 = SY-INDEX.

    LINE-COL2 = SY-INDEX ** 2.

    INSERT LINE INTO TABLE ITAB.

    ENDDO.

    LINE-COL1 = 1.

    DELETE TABLE ITAB: FROM LINE,

    WITH TABLE KEY COL1 = 3.

    LOOP AT ITAB INTO LINE.

    WRITE: / LINE-COL1, LINE-COL2.

    ENDLOOP.

    The output is:

    2 4

    4 16

    The program fills a hashed table with a list of square numbers. The DELETE

    statement delete the lines from the table where the key field COL1 has the contents 1 or 3.

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 11, 2007 at 06:03 AM

    Hi,

    Is vendor assignment = 00000000.if yes we can do like this.

    Loop at itab.

    delete itab where <vendor assignment> = '00000000'.

    endloop.

    it will delete the vendor assignment .

    Regards,

    Nagaraj

    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.