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

insert

hi to all

i need to insert two field from internal table to database table should i use like modify ztab from table

itab or

update ztab from table itab.

thanks in advace.

kiran kumar

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:30 PM

    Hi,

    You can use both..But all the other fields (other than the two fields) needs to have the old value to store the correct values in the table..

    Otherwise..You can use this..

    UPDATE ZTABLE SET FIELD1 = 'ASDF'

    FIELD2 = 'ADSF'

    WHERE KEY_FIELD = 'DF'.

    For the above statement you don't require the other field values..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi Naren,

      when i use it is creating new row and placing the values in noew row same with update but i need the values to be in same line of old values of data base

      thanks in advance

      kiran kumar

  • Posted on Oct 16, 2006 at 09:37 PM

    Hi,

    From SAP help:

    MODIFY inserts new lines or updates existing lines in dadatabase table). If a linewith the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed.

    Krzys

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 16, 2006 at 09:56 PM

    Hi,

    Check this..

    data: itab like ztable occurs 0 with header line.

    Select * from ztable into table ITAB.

    • For updating

    READ TABLE itab index 1.

    itab-field1 = 'ABC'.

    MODIFY itab index 1.

    • For Inserting..

    ITAB-KEY_FIELD = 'ASD'.

    ITAB-FIELD1 = 'ASDF'.

    APPEND ITAB.

    • To update the database table.

    MODIFY ZTABLE FROM TABLE ITAB.

    For the records that are already there it will be updated..If the record is not there then it will be inserted...That is how MODIFY works..

    Thanks,

    Naren

    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.