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

Database insert

Hi all,

My database table has 4 key fields.

I have created a user dialog for data modifications.

but using ABAP Open SQL stmts like INSERT, duplicate entries are also inserted with no checking.

What is the solution ??

thanx in advance

Sandeep

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Feb 18, 2005 at 01:41 PM

    I would suggest that you check out the F1 help on the keyword INSERT. It has a lot of good info. A little confused by your problem though, the INSERT statement checks the table for duplicate key before actually doing the INSERT, if the key is already there, the INSERT statement will fail and give you a SY-SUBRC <> 0. Are you absolutly sure that your key fields have been defined correctly?

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 01:48 PM

    Hi Sandeep,

    Obviously there's something that has gone wrong somehwere. Seems like you are doing something with a Custom Table (may be you have just finished creating it ??:-))

    1. Go to SE16 and see the entries of the table. I'm sure you will not find any two rows with identical values for the key fields.

    2. If you do, then please provide the key fields with their technical attributes and also the rows in the table which you think are duplicates.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 21, 2005 at 11:38 AM

    Hi Sandeep,

    If you are sure that the records are duplicated in the table, then it means you haven't checked the 'Key' column (go into se11 for the table) for all the 4 fields in the Z table to make them the primary key. When INSERT encounters a record with a duplicate key, it terminates with a runtime error unless you have given the addition 'ACCEPTING DUPLICATE KEYS '.

    regards,

    Madhavan

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi All,

      Allow me to further clarify what I stated earlier. I think it has amounted to some confusion. When I said "When INSERT encounters a record with a duplicate key, it terminates with a runtime error unless you have given the addition 'ACCEPTING DUPLICATE KEYS ' ", it was based on the doubtless assumption that we can never find a record in any of the SAP tables with a duplicate key. I did not mean to say that the addition 'ACCEPTING DUPLICATE KEYS' will literally accept duplicate keys. For example when 100 records are inserted in one go and if the 50th record has a duplicate key, then it merely skips this record setting the sy-subrc to 4 and moves on to the next record for insertion.

      Hope I have cleard the confusion (if any) that I have caused.

      regards,

      Madhavan

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.