‎2006 Feb 24 4:04 AM
Hi All,
What is the difference betwenn "update DB table" and " Modify DB table"?
Plz reply
Regards
Saurabh.
‎2006 Feb 24 4:07 AM
Update DB table:
Inserts new entries if not available or changes the content.
Modify:
Changes the existing table rows.
‎2006 Feb 24 4:07 AM
Update DB table:
Inserts new entries if not available or changes the content.
Modify:
Changes the existing table rows.
‎2006 Feb 24 4:10 AM
Wenceslaus,
I am sorry but you got it reversed. Update updates the existing records in the database and if a record does not exist, it will fail.
Modify on the other hand will insert the records if the records with the same key does not exist and updates if they exist.
Srinivas
‎2006 Feb 24 4:11 AM
Update will not insert new records if the records are not there.
‎2006 Feb 24 4:09 AM
Update database table command will insert a new entry. But MODIFY will check if record already exist, if it exist then it will modify existing record else it will insert new record in db table.
For more details here is screenshot from F1 help -
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.
‎2006 Feb 24 4:10 AM
Hi,
Modify:
If the value of key fields in the internal table matches with the key fields values in database table,modify will update the existing entry.Otherwise,it will insert new entry.
Update:
To update db table,it is mandatory that the value of key fields in internal table should match with database table.
Kindly reward points by clikcing the star on the left of reply,if it helps.
‎2006 Feb 24 4:12 AM
Hi Saurabh,
To insert lines into a database table regardless of whether there is already a line in the table with
the same primary key .. we use MODIFY..
If the database already contains a line with the same primary key as the line to be inserted,
MODIFY works like UPDATE, that is, the line is changed.
For performance reasons, you should use MODIFY only if you cannot distinguish between these
two options in your ABAP program.
regards
satesh
‎2006 Feb 24 4:14 AM
Hi Srinivas,
Yes. You are right.
Update DB table:
Changes the existing table rows.
Modify:
Inserts new entries if not available or changes the content.
‎2006 Feb 24 4:16 AM
Somewhat different syntax. Simply do F1 on each and you'll see the differences.
Rob
‎2006 Feb 24 4:16 AM
Update is generally used for changing rows in database tables
update vbak set cmgst = 'C' where kunnr = '999999999'
Modify generally relates to internal table changes.
loop at itab into wa.
wa-myField = 'X'.
modify table itab from wa.
endloop.
‎2006 Feb 24 4:19 AM
HI
<u>MODIFY</u> TO INSERT LINES INTO DATABSE TABLE REGARDLESS OF WHETHER THE PRIMARY KEY OF THIS LINE IS ALREADY EXISTS, USE MODIFY STATEMENTS.
IF THE DATABASE TABLE CONTAINS NO LINE WITH SAME PRIMARY KEY AS THE LINE TO BE INSERTED, MODIFY words LIKE <u>INSERT</u> IS USED.
IF THE DATABASE TABLE ALREADY CONTAINS LINE WITH SAME PRIMARY KEY AS THE LINE TO BE INSERTED,MODIFY words LIKE <u>UPDATE</u> ie THE LINE IS CHANGED
FOR MORE DOCUMENTATION GO THROUGH
<a href="http://www.sappoint.com/faq/faqsql.pdf">http://www.sappoint.com/faq/faqsql.pdf</a>
IF IT FINDS USEFUL PLEASE REWARD POINTS
REGARDS
ANOOP
‎2011 Jul 28 10:35 AM