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: 

REGARDING "modify and update"

Former Member
0 Kudos
363

dear experts

can u please tell me whats difference Modify & Update statements

thnx

7 REPLIES 7

Former Member
0 Kudos
153

Refer

Former Member
0 Kudos
153

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.

Update - updates the existing records.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/update.htm

Modify - modifys the existing records or creates a new record if the primary key does not match.

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/modify_d.htm

Regards,

Priyanka.

Former Member
0 Kudos
153

Hi,

<b>UPDATE target source.</b>

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.

<b>MODIFY dbtab</b>

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.

Regards,

Padmam.

Former Member
0 Kudos
153

<b>UPDATE target source.</b>

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.

<b>MODIFY dbtab</b>

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.

Regards,

Pavan.

Former Member
0 Kudos
153

Hi Prakash,

MODIFY - If the record is already there it will MODIFY it, but if record is not there it will create the new record.

UPDATE - If the record is already there it will MODIFY (UPDATE) it , but if record is not there then it will do nothing (sy-subrc = 4)

Regards,

Atish

Former Member
0 Kudos
153

HI,

<b>UPDATE</b>

The Open SQL statement for changing data in a database table is:

UPDATE <target> <lines>.

It allows you to change one or more lines in the database table <target>. You can only change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.

<b>MODIFY</b>

To insert lines into a database table regardless of whether there is already a line in the table with the same primary key, use the following:

MODIFY <target> <lines>.

If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, 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.

For performance reasons, you should use MODIFY only if you cannot distinguish between these two options in your ABAP program.

You can add or change one or more lines <lines> in a database table <target>. You can only insert or change lines in an ABAP Dictionary view if it only contains fields from one table, and its maintenance status is defined as Read and change. You may specify the database table <target> either statically or dynamically.

Regards

Sudheer

Former Member
0 Kudos
153

Hi,

SELECT - It reads data from database tables.

INSERT - It adds rows to database tables.

UPDATE - It changes the contents of rows of database tables.

MODIFY - It inserts rows into database tables or changes the content of existing rows.

DELETE - It deletes rows from database tables.

OPEN CURSOR, FETCH, CLOSE CURSOR - It reads rows of database tables using the cursor.

Refer this link

http://aspalliance.com/1136_Database_Access_using_Advanced_Business_Application_Programming_ABAP

Regards

Gaurav