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

Insert & Modify statems

Hello,

In my code. I used INSERT stat for updating in DB Tab from Itab. I am getting dump,If i try to update existing recor. Dump is "The ABAP/4 Open SQL array insert results in duplicate database records"

I can avoid the prob by using MODIFY stat. Please correct me if i am wrong.

Thnx.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

12 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 08:58 AM

    Modify will insert record if it doesnt exist otherwise it will update the non key fields if it exists. But while Using modify statement be careful if u have any field with conversion or any rules follow them carefully otherwise it will treat it as new record and it will insert.

    Example: MARA-Matnr = 100.

    mara-matnr = 0000000000000100. Both are same only but make sure you will be following the rules.

    Edited by: Phanindra Annaparthi on Feb 26, 2009 9:59 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2009 at 08:59 AM

    Hi,

    INSERT statement inserts a new record into the db table i.e., no duplicates (on primary key)

    UPDATE statement updates the existing records using the combination of primary keys.

    MODIFY statements works as INSERT + MODIFY i.e., if record found based on primary key then update, if not found then insert.

    Hope this helps you.

    Regards,

    Tarun

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2009 at 08:59 AM

    Yes,you can use modify statement.

    It will act such that if you dont have record it will create new one

    and modifies the record if already exists.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:00 AM

    check for the primary keys ....they should be different ..from the data existing in the db table.

    use modify if u have to chage only one fieldd.....

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:00 AM

    Hi Sandya,

    You are trying to insert duplicate records.

    You must be having a primary key right?

    So check that no 2 such fieds are same.

    Use delete adjacent duplicates and then try to insert.

    Also If its a sorted table and your entries are not in the sorted form it will give Dump.

    Sort it too!!

    Much Regards,

    Amuktha.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2009 at 09:01 AM

    Hi,

    Insert is insert the record in a table ..

    modify is used to update the record entry , if the record is not their in table then it acts like an insert only...

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 26, 2009 at 09:01 AM

    Hi,

    You can do a select before doing the insert, to check which records already exist. Then pick out those records which are not yet in the table and do your insert. and use modify for the existing records if necessary.

    Alternatively you can do a modify.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:01 AM

    Hi,

    By using the INSERT it will checks with the primary key entries in table if it find the duplicating..and tyring to insert it goes to dump.

    so to avoid that dump use the MODIFY statiememt..

    this will also check the primary key entry.....if it is there and does not update..but it wont go dump.

    using UPDATE you can modify the non-primary key fileds update.

    hope this info useful to you.

    Regards!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:01 AM

    Hi Sandya,

    Use the MODIFY command instead of INSERT statement.

    If there is a record exists with the key fields then MODIFY command will overwrite the non key fields and the entry is saved in the database.

    Regards,

    Phani.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 26, 2009 at 09:02 AM

    Whenever you are using INSERT, it checks if the reocrd with same KEY fields exists, If yes , it gives dump.

    But in MODIFY, if an record with same KEY found, it just updated that record, if not found, it acts same as INSERT.

    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.