7 Replies Latest reply: Jan 6, 2008 1:34 PM by Sravani K RSS

Difference  between update and modify

Naresh kumar
Currently Being Moderated

Hi

Experts,

 

Difference  between update and modify.

  • Re: Difference  between update and modify
    Uwe Schieferstein
    Currently Being Moderated

    Hello Naresh

     

    MODIFY = UPDATE or INSERT

     

     

    The statement UPDATE only changes an existing DB entry otherwise sy-subrc <> 0

    The statement MODIFY updates an existing DB entry or, in no matching entry exists, inserts a new entry into the DB table.

     

     

    Regards,

      Uwe

  • Re: Difference  between update and modify
    Mahalakshmi Padmanaban
    Currently Being Moderated

    MODIFY - If record is available it modifies otherwise it wont modify.

     

    UPDATE - If record is available its update the record otherwise it creates a new record.

     

    Also,

     

    INSERT - Add a new record into the database table.

     

    Regards,

    Maha

  • Re: Difference  between update and modify
    Muralikrishna Nadendla
    Currently Being Moderated

    Hi Naresh,

     

    Modify (or) Update: this statement is normally preferble to insert or modify the D/B table, because system will check the table before insert the record, if it is exists, then it modifys that record, if not it created new record,

      where as if you use Insert statement, it only try's to Insert the Record into D/B table, Even if it is already exists also, some times there is a chance to get Short Dump also....

     

    Thanks,

    Murali.Nadendla

  • Re: Difference  between update and modify
    Sriram Ponna
    Currently Being Moderated

    Hi,

     

    Using update statement you chnage the contents of the record.

     

    Using modify statement you can insert a record into the table and also update the content of the existing record of the table.

     

    Thanks,

    Sriram Ponna.

  • Re: Difference  between update and modify
    Mahesh kumard
    Currently Being Moderated

    Modify will work for both insert and updation of the DB..

     

    But Update will only update the values in the table..

  • Re: Difference  between update and modify
    Chandra Prakash
    Currently Being Moderated

    Hi,

     

    MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.

     

    UPDATE - Will update the table, errors out if the data is not found.

     

    In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.

     

    INSERT - Inserting Data in Database Tables

     

    Variants:

    1. INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.

    INSERT INTO (dbtabname) CLIENT SPECIFIED VALUES wa.

    2. INSERT dbtab CLIENT SPECIFIED FROM TABLE itab. oder

    INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.

    3. INSERT dbtab CLIENT SPECIFIED. oder

    INSERT *dbtab CLIENT SPECIFIED. oder

    INSERT (dbtabname) CLIENT SPECIFIED ... .

     

    Effect Adds new records to a database table (see relational

    database). You can specify the name of the database table

    either directly in the program in the form dbtab or at runtime

    as the contents of the field dbtabname. In either case, the

    database table must be declared in the ABAP Dictionary. You

    can only insert data using a view if the view refers to a

    single table and has the maintenance status "No restriction"

    in the ABAP Dictionary.

     

    By default, data is only inserted in the current client.

    However, if you use the CLIENT SPECIFIED addition, you can

    switch off the automatic client handling. This enables you to

    enter data for any client in a cross-client table, not just in

    the client in which you are logged on. In this case, the

    client field is treated like a normal field to which you can

    assign a value in the work area.

     

    MODIFY - Change a database table

     

    Variants:

     

    1. MODIFY dbtab. or

    MODIFY *dbtab. or

    MODIFY (dbtabname) ... ..

    2. MODIFY dbtab FROM TABLE itab. or

    MODIFY (dbtabname) FROM TABLE itab.

    3. MODIFY dbtab VERSION vers. or

    MODIFY *dbtab VERSION vers.

     

    Effect Inserts new lines or updates existing lines in a database

    table (s. relational database). If a line with the specified

    primary key already exists, an UPDATE is executed. Otherwise,

    an INSERT is performed. You can specify the name of the

    database table either in the program itself in the form MODIFY

    dbtab ... or at runtime as the contents of the field dbtabname

    in the form MODIFY (dbtabname) ... . In both cases, the

    database table must be defined in the ABAP Dictionary.

    Normally, records are inserted or updated only in the current

    client. Data can only be inserted or updated using a view, if

    the view refers to a single table and was created in the ABAP

    Dictionary with the maintenance status "No restriction".

     

    MODIFY belongs to the Open SQL command set.

     

    When the statement has been executed, the system field

    SY-DBCNT contains the number of edited lines.

     

    'Insert' will add a new record or a new row into the database table.

    'Update' will modify a record in the DB table.

    'Modify' it is a combination of both insert and update...

     

    Also check these links

     

     

     

     

     

     

    UPDATE->

    Bundling using Function Modules for Updates

    If you call a function module using the statement CALL FUNCTION ... IN UPDATE TASK, the function module is flagged for execution using a special update work process. This means that you can write the Open SQL statements for the database changes in the function module instead of in your program, and call the function module at the point in the program where you would otherwise have included the statements. When you call a function module using the IN UPDATE TASKaddition, it and its interface parameters are stored as a log entry in a special database table called VBLOG.

     

    The function module is executed using an update work process when the program reaches the COMMIT WORKstatement. After the COMMIT WORKstatement, the dialog work process is free to receive further user input. The update work process is responsible for the update part of the SAP LUW. The statement COMMIT WORKcloses the SAP LUW for the dialog part of the program and starts the update. The SAP LUW is complete once the update process has committed or rolled back all of the database changes. Bundling using function modules is called Update.

     

    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/content.htm

     

    MODIFY->

    To modify the lines of a completed list from within the program, use the MODIFY LINE statement. There are two ways to specify the line you want to modify:

     

    · Explicitly:

     

    MODIFY LINE n OF CURRENT PAGE

    modifications.

     

    You can refer to the line most recently read:

     

    MODIFY CURRENT LINE modifications.

     

    This statement modifies the line most recently read by means of line selection (F2) or read by the READ LINE statement.

     

    Apart from the ones described above, the modificationsaddition contains several other possibilities to modify the line. For more information on this and on the individual additions of the MODIFY LINEstatement , refer to the keyword documentation.

    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba4b235c111d1829f0000e829fbfe/content.htm

     

     

    Check out the thread

     

     

     

    Regards,

    Chandru

     

  • Re: Difference  between update and modify
    Sravani K
    Currently Being Moderated

    Hi Naresh,

     

    UPDATE -- A update statement will update with new values  in an Database table.

     

    WHERE AS

     

    MODIFY -- A modify would insert a new row into the table if its not present till then.If it exists then it would simply update it.

Actions