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

Insertion + modification in a database table

Hi all,

I want to insert and as well as update a database table with values in an internal table.

The new records should be inserted from the internal table and the existing records should be modified from the internal table.

is there any keyword to do both insertion and updation. or else, please suggest me a logic to do this.

Thanks in advance,

rajan

Use SAP Documentation or Press F1

Edited by: Vijay Babu Dudla on Dec 15, 2008 11:24 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • Best Answer
    Posted on Dec 15, 2008 at 06:49 AM

    Hi,

    use key word MODIFY , this will do your purpose.

    if record is not there it INSERTS else it UPDATES the record in the database

    Take F1 help for more info

    Regards

    Ramchander Rao.K

    Edited by: ramchander krishnamraju on Dec 15, 2008 7:50 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2008 at 06:22 AM

    <<removed_by_moderator>>

    Edited by: Vijay Babu Dudla on Dec 15, 2008 11:24 PM

    Edited by: Vijay Babu Dudla on Dec 15, 2008 11:27 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2008 at 06:24 AM

    Hi,

    Firsr fill the internal table with the values which u want to insert into database table

    Then Use INSERT,UPDATE ....

    For more details how to use INSERT ,UPDATE for database table Press F1 on that ....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 15, 2008 at 06:33 AM

    Hi,

    use the keywords like INSERT & UPDATE.

    Regards,

    Sudhir K.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 16, 2008 at 05:05 AM

    Hi,

    Use MODIFY statement to update the database table.

    This will check the primary key, if it is already present then it updates the database otherwise inserts a new record.

    Press F1 help on Modify statement for the syntax and hope this solves your problem.

    Regards,

    Lavanya.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 17, 2008 at 03:25 AM

    Hi usman,

    key words are INSERT and UPDATE chek this example.

    CASE SY-UCOMM.

    WHEN 'INSERT'.

    MOVE LFA1 TO ITAB.

    APPEND ITAB.

    INSERT INTO LFA1 VALUES ITAB.

    IF SY-SUBRC = 0.

    MESSAGE I000(0) WITH 'RECORD INSERTED'.

    WHEN 'UPDATE'.

    MOVE LFA1 TO ITAB.

    APPEND ITAB.

    UPDATE LFA1 FROM TABLE ITAB.

    IF SY-SUBRC = 0.

    MESSAGE I000(0) WITH 'RECORD UPDATED'.

    ELSE.

    MESSAGE E000(0) WITH 'RECORD NOT UPDATED'.

    ENDIF.

    Edited by: SHAIK JAILABDIN on Dec 17, 2008 4:25 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2008 at 05:11 AM

    MODIFY dbtab FROM TABLE itab.or

    MODIFY (dbtabname) FROM TABLE itab.

    Effect

    Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying the lines to be inserted or updated and the relevant values are taken from the internal table itab. The lines of the internal table itab must satisfy the same conditions as the work area wa in addition 1 to variant 1.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 17, 2008 at 05:51 AM

    Hi,

    use key word MODIFY , this will do your purpose.

    if record is not there it INSERTS else it UPDATES the record in the database

    Take F1 help for more information.

    Regards

    Amit.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 09:47 AM

    Hi,

    INSERT statement only inserts record into database table from internal table. But MODIFY statement to update the database table and also it checks primary key.if the record already present then it updates the database otherwise inserts a new record.

    Regards

    Md.MahaboobKhan

    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.