Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

differ

Former Member
0 Kudos

what is the difference between update and modify keywords.

10 REPLIES 10

former_member188827
Active Contributor
0 Kudos

hi

UPDATE dbtab

Syntax

UPDATE target source.

Effect:

The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed.

System fields

The statement UPDATE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning

0 At least one line has been changed.

4 At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.

Note

The changes are definitively copied to the database with the next database commit. Until that point, they can still be undone using a database rollback.

MODIFY dbtab

Syntax

MODIFY target FROM source.

Effect

The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.

System fields

The MODIFY statement sets the values of the sy-subrc and sy-dbcnt system fields.

sy-subrc Meaning

0 At least one line is inserted or changed.

4 At least one line could not be processed since there is already a line with the same unique name secondary index in the database table.

The MODIFY statement sets sy-dbcnt to the number of processed lines.

Note

The changes are transferred finally to the database table with the next database commit. Up to that point, they can be reversed using a database rollback.

plz reward points if it helps

Former Member
0 Kudos

Hi

MODIFY {itab_line|itab_lines}.

This statement changes the content of one or several itab_line or itab_lines lines that can be specified using the table key or the table index.

System fields

sy-subrc Meaning 0 At least one line was changed.

4 No lines were changed, since no suitable line was found for the insertion using the table key, or the specified index was greater than the current number of lines for the insertion using the table index.

Apart from using the MODIFY statement, the content of an individual table line can be changed using assignments to field symbols and dereferenced data references that point to the table line.

<b>UPDATE target source.</b>

The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed.

System fields

The statement UPDATE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning 0 At least one line has been changed.

4 At least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.

The changes are definitively copied to the database with the next database commit. Until that point, they can still be undone using a database rollback.

reward if usefull

Former Member
0 Kudos

Hi Sandeep,

When UPDATE is used - this option will update the records into the table only if the entry exists. If it does not exists, it will return error.

When MODIFY is used - this option will UPDATE the record if it already exists and if the record does not exist it will be INSERTED.

<b>Reward points for helpful answers</b>.

Best Regards,

Ram.

Former Member
0 Kudos

hi,

The MODIFY statement inserts one or several lines specified in source in the database table specified in target, or overwrites existing lines.

The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed.

Former Member
0 Kudos

MODIFY --sets SY-DBCNT to the number of lines processed.

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

UPDATE --sets SY-DBCNT to the number of lines changed.

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

record

Former Member
0 Kudos

hi,

update will append a new line and store that in internal table whereas modify will modify the existing value in the table.

Reward me if helpful.

Former Member
0 Kudos

hi,

in simple words,

update:

-- used for native and open sql statements.

-- when used updates the record and when record doesn't exists it gives error.

--- doesn't affect sy-dbcnt value.

modify:

-- used only for open sql statements.

-- when used updates the record and if record doesnt exists then it creates a new record and appends to table.

i.e affects sy-dbcnt value.

if helpful reward some points.

with regards,

Suresh aluri.

Former Member
0 Kudos

hi,

update will update the values only if that record exists.

modify will modify the values if the record exists .even if that record does not exist it will insert that record .

Reward with points if helpful.

Message was edited by:

Vinutha YV

Former Member
0 Kudos

hi ,

modify is used for internal table and update is used for physical table

Former Member
0 Kudos

Hi,

'<b>Update'</b> will modify a record in the DB table.

'<b>Modify'</b> it is a combination of both insert and update...

Regards,

Kumar.