11-14-2006 6:00 AM
Dear SDN's,
I would like to know differences in usage of below statements.
MODIFY <dbtab> FROM <wa>.
UPDATE <dbtab>
SET <col> = <value>
WHERE <keycol> = <Keycolumn Value>.
The <dbtab> has been constantly updating through background job and as well thru' front-end.
Regards,
Ramki.
11-14-2006 6:02 AM
The statement UPDATE changes the content of one or more lines of the database table specified in target.
The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.
So comparing thsi its always suggested to use <b>MODIFY</b>
Regards
- Gopi
11-14-2006 6:02 AM
The statement UPDATE changes the content of one or more lines of the database table specified in target.
The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.
So comparing thsi its always suggested to use <b>MODIFY</b>
Regards
- Gopi
11-14-2006 6:04 AM
hi,
<b> modify statemnt</b> will modify a record if there is record having the same key like that of record in work area.
<i>Same like above in the case of data base table</i>
if there is no record in itab with key of work area record, it will insert a new record in itab.
look this sample code.
loop at itab into wa.
wa-field1 = data1.
wa-field2 = data2.
wa-field 3= data3.
modify itab from wa transporting field1 field2 field3 where key_field = wa-keyfield. "there shuld not be any chang in key field.
endloop.
<b>update</b>
never use update statements in standard SAP tables.
try to use modfy maximaum
rgds
anver
if hlped pls mark points
11-14-2006 6:06 AM
Hi Ramakrishna,
If your requirement is to just change the existing value (modifying) then use UPDATE which would be faster than MODIFY , as MODIFY will do few checks before updating a values as it will check the database entry and if it exists it will update other wise it will create new entry .simply
MODIFY = INSERT + UPDATE.
<u><i>See this lines from ABAPHELP.</i></u>
<b>Automatic definition of INSERT and UPDATE is expensive. You should therefore use MODIFY only if you cannot define the INSERT and UPDATE cases yourself in the program.</b>
Regards,
Raghav
11-14-2006 6:20 AM
Read below info.
If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like IINSERT - that is, the line is added.
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.
<b>For performance reasons, you should use MODIFY only if you really cannot distinguish between these two options in your program.</b>
The contents of the work area wa are written to the database table dbtab. The work area wa must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.
MODIFY target FROM wa.
If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted.
If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten.
If the line could not be processed for example, because a line with the same unique secondary index exists in the database sy-subrc is set to 4, otherwise to 0.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/content.htm
Update
Authorization checks are not supported by the UPDATE statement. You must include these in the program yourself.
Changes to lines made with the UPDATE command only become final after a database commit.
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/update.htm
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers