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

Duplicate entries should not entered in sap data base

Hi Gurus,

Please answer for this question

i had to write the code in such a way that duplicate entries should not entered in sap data base?

Thanks/

Radha.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:36 AM

    Hi,

    first sort your internal table on based of primary keys,then apply the Delete duplicate adjacent statement comparing the primary fields and then you can use the modify statement for the database update.

    Because modify statement first check the primary keys and then it will do database update.If the primary keys are present then it will just update the whole records otherwise it will insert a new records.

    In this way modify statement will take care of both updation and insertion of records.

    I hope this will help you.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:19 AM

    hi,

    sort your final internal table based on primary key fields of your dbase

    table.

    delete the dupliacte entries by using

    delete adjacent duplicates from (final int table ) comparing key fields.

    regards

    siva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:21 AM

    Hi,

    delete adjucent duplicate from <database table>.

    Thanks

    VIkranth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:25 AM

    HI,

    First SORT the internal table using the key fields.

    Then use the stmt DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

    Hope this solves the problem.

    Thanks and regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:29 AM

    hi..

    generally duplicate entries wont get inseted in your sap database if your duplicate entries are primary key.it will give a dump.

    however if this is happening then you can us delete adjacent duplicates from the intrnal table itself and then inset in your database.thats a better option rather then deleting them at database level.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 04:59 AM

    Hi,

    First SORT your internal table with a unique key.

    Then use DELETE DUPLICATE ADJACENT this will delete the duplicate adjacent rows of ur internal table comparing the field.

    Try out this sample program,

    DATA: BEGIN OF connection,

    cityfrom TYPE spfli-cityfrom,

    cityto TYPE spfli-cityto,

    distid TYPE spfli-distid,

    distance TYPE spfli-distance,

    END OF connection.

    DATA connection_tab LIKE SORTED TABLE OF connection

    WITH NON-UNIQUE KEY cityfrom cityto

    distid distance.

    SELECT cityfrom cityto distid distance

    FROM spfli

    INTO TABLE connection_tab.

    DELETE ADJACENT DUPLICATES FROM connection_tab.

    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.