08-06-2007 7:25 AM
08-06-2007 7:27 AM
Hi
See this doc
<b>MODIFY</b>
... FROM { {wa} | {TABLE itab} }.
1. ... FROM wa
2. ... FROM TABLE itab
A wa data object that is not table-type or an itab internal table can be specified after FROM. On the one hand the content of the data objects determines whether the line(s) are inserted or changed, and on the other hand, which values are inserted or used for changes.
To insert or change several lines in a database table, use the following:
MODIFY <target> FROM TABLE <itab> .
Those lines of the internal table <itab> for which there is not already a line in the database table with the same primary key are inserted into the table. Those lines of the internal table <itab> for which there is already a line in the database table with the same primary key overwrite the existing line in the database table. The same rules apply to the line type of <itab> as to the work area <wa> described above.
SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table
<b>UPDATE</b>
... { {SET set_expression [WHERE sql_cond]}
| {FROM wa|{TABLE itab}} }.
1. ... SET set_expression [WHERE sql_cond]
2. ... FROM wa
3. ... FROM TABLE itab
The specifications in source define which rows and columns are changed. Either individual columns are changed using the addition SET or entire rows are overwritten using the addition FROM.
After FROM, either a non-table-type data object wa or an internal table itab can be specified. The content of these objects determines - on the one hand - which row(s) is/are changed, and - on the other hand - which values are used to overwrite the row(s).
Check out these related threads
<b>Reward points for useful Answers</b>
Regards
Anji
08-06-2007 7:27 AM
HI,
Update we are using to new record update
But modify we are using for not only modifying existing records if it is not existing it will insert in new record in a table.
Regards,
Nandha
Reward if it helps.
08-06-2007 7:28 AM
Update - only updates the record
Modify -update or modifies if record exists else will create a new record
Regards
Gopi
08-06-2007 7:28 AM
Hi,
Update will modify the particular record/s.
Whereas modify the table with updating the existing entries and if the record which u r updating is not found it will save it as a new record.
Thanks & Regards
Santhosh
08-06-2007 7:39 AM
HI Santosh,
Both are Used to Update database records,
In Case of UPDATE:
- it is used to update the changes to the existing record.
- if the referred record is not found, it wil create a new entry & add tat record to the Table.
In Case of MODIFY
- This is also used to Update the changes to an existing record, however wen the record is not found a new entry wil not be created and wil not return sy-subrc=0.
<b>Reward Points IF Useful*</b>
08-06-2007 7:43 AM
Hi,
As everybody suggested update will update the dataset if it exists.
whereas if u use modify it will check if dataset exists it will modify and if dataset doesn't exists then it will create a new one.
say for e.g
TAble-ztable
Sno name age
1 tushar 18
update ztable set name = 'prakhar' where sno = 1.
or
ztable-sno ='1'.
ztable-name = 'prakhar'.
ztable-age = '18'.
modify ztable.
Now if you want to update record one use update command or modify statement.Then only difference comes when record doesn't exist then modify will insert a new one.
say for e.g if we use modify like this instead of above one
ztable-sno ='2'.
ztable-name = 'prakhar'.
ztable-age = '18'.
modify ztable.
than table will be.
dataset -ztable
Sno name age
1 tushar 18
2 prakhar 18
Please reward points for the same.
Message was edited by:
Prakhar Saxena