Here's a very common syntactic question: What's the difference between INSERT, UPDATE, and MODIFY?
The answer is plain and simple:
INSERT - inserts a new record. INSERT expects that a record with the required key does NOT exist in the table. Therefore, if a record with the same key already exists, a runtime error occurs. For more details on INSERT, visit here.
UPDATE - update an existing record. UPDATE expects that a record with required key exists in the table. If a record with the required key does not exist, it issue an error (sy-subrc is 4). For more details on UPDATE, visit here.
MODIFY - acts like a combination of INSERT and UPDATE. If a record with the specified key does not exist, it adds it to the table. If a record with the specified key does exist, it modifies it. So MODIFY actually acts like "Insert or change record". To read more about MODIFY, visit here.
To summarize:
INSERT - adds a new record to the table. If the row (key) exists, issues an error.
UPDATE - updates an existing record to the table. If the row (key) does not exist, issues an error.
MODIFY - If the key exists, modifies the record. If the key does not exist, adds the record to the table.
Hi,
ReplyDeleteGive me diffference between modify , append and update?
If possible give me with example.
Thanks & regards
venkravi
hi,
ReplyDeletemodify it behaves as both update and insert.
if record is there it behaves as update or like insert.
update it changes the already updated record
append : it add new record as the last row
regards
vikhi
Append is used for internal/local table. Modify, update, insert are used for transparent tables.
ReplyDelete