Application Development and Automation 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: 
Read only

update

Former Member
0 Likes
491

what is the difference between update and modify.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
461

hi

good

MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.

UPDATE - Will update the table, errors out if the data is not found.

In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.

INSERT - Inserting Data in Database Tables

Variants:

1. INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa.

INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa.

2. INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. oder

INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.

3. INSERT dbtab [CLIENT SPECIFIED]. oder

INSERT *dbtab [CLIENT SPECIFIED]. oder

INSERT (dbtabname) [CLIENT SPECIFIED] ... .

Effect Adds new records to a database table (see relational

database). You can specify the name of the database table

either directly in the program in the form dbtab or at runtime

as the contents of the field dbtabname. In either case, the

database table must be declared in the ABAP Dictionary. You

can only insert data using a view if the view refers to a

single table and has the maintenance status "No restriction"

in the ABAP Dictionary.

By default, data is only inserted in the current client.

However, if you use the CLIENT SPECIFIED addition, you can

switch off the automatic client handling. This enables you to

enter data for any client in a cross-client table, not just in

the client in which you are logged on. In this case, the

client field is treated like a normal field to which you can

assign a value in the work area.

MODIFY - Change a database table

Variants:

1. MODIFY dbtab. or

MODIFY *dbtab. or

MODIFY (dbtabname) ... ..

2. MODIFY dbtab FROM TABLE itab. or

MODIFY (dbtabname) FROM TABLE itab.

3. MODIFY dbtab VERSION vers. or

MODIFY *dbtab VERSION vers.

Effect Inserts new lines or updates existing lines in a database

table (s. relational database). If a line with the specified

primary key already exists, an UPDATE is executed. Otherwise,

an INSERT is performed. You can specify the name of the

database table either in the program itself in the form MODIFY

dbtab ... or at runtime as the contents of the field dbtabname

in the form MODIFY (dbtabname) ... . In both cases, the

database table must be defined in the ABAP Dictionary.

Normally, records are inserted or updated only in the current

client. Data can only be inserted or updated using a view, if

the view refers to a single table and was created in the ABAP

Dictionary with the maintenance status "No restriction".

MODIFY belongs to the Open SQL command set.

When the statement has been executed, the system field

SY-DBCNT contains the number of edited lines.

reward point if helpful.

thanks

mrutyun^

3 REPLIES 3
Read only

Former Member
0 Likes
462

hi

good

MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.

UPDATE - Will update the table, errors out if the data is not found.

In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.

INSERT - Inserting Data in Database Tables

Variants:

1. INSERT INTO dbtab [CLIENT SPECIFIED] VALUES wa.

INSERT INTO (dbtabname) [CLIENT SPECIFIED] VALUES wa.

2. INSERT dbtab [CLIENT SPECIFIED] FROM TABLE itab. oder

INSERT (dbtabname) [CLIENT SPECIFIED] FROM TABLE itab.

3. INSERT dbtab [CLIENT SPECIFIED]. oder

INSERT *dbtab [CLIENT SPECIFIED]. oder

INSERT (dbtabname) [CLIENT SPECIFIED] ... .

Effect Adds new records to a database table (see relational

database). You can specify the name of the database table

either directly in the program in the form dbtab or at runtime

as the contents of the field dbtabname. In either case, the

database table must be declared in the ABAP Dictionary. You

can only insert data using a view if the view refers to a

single table and has the maintenance status "No restriction"

in the ABAP Dictionary.

By default, data is only inserted in the current client.

However, if you use the CLIENT SPECIFIED addition, you can

switch off the automatic client handling. This enables you to

enter data for any client in a cross-client table, not just in

the client in which you are logged on. In this case, the

client field is treated like a normal field to which you can

assign a value in the work area.

MODIFY - Change a database table

Variants:

1. MODIFY dbtab. or

MODIFY *dbtab. or

MODIFY (dbtabname) ... ..

2. MODIFY dbtab FROM TABLE itab. or

MODIFY (dbtabname) FROM TABLE itab.

3. MODIFY dbtab VERSION vers. or

MODIFY *dbtab VERSION vers.

Effect Inserts new lines or updates existing lines in a database

table (s. relational database). If a line with the specified

primary key already exists, an UPDATE is executed. Otherwise,

an INSERT is performed. You can specify the name of the

database table either in the program itself in the form MODIFY

dbtab ... or at runtime as the contents of the field dbtabname

in the form MODIFY (dbtabname) ... . In both cases, the

database table must be defined in the ABAP Dictionary.

Normally, records are inserted or updated only in the current

client. Data can only be inserted or updated using a view, if

the view refers to a single table and was created in the ABAP

Dictionary with the maintenance status "No restriction".

MODIFY belongs to the Open SQL command set.

When the statement has been executed, the system field

SY-DBCNT contains the number of edited lines.

reward point if helpful.

thanks

mrutyun^

Read only

Former Member
0 Likes
461

Use the help in the ABAP editor.

Use the search on this forum.

Update - record has to be on table.

Modify - if record is not there it will be inserted.

Read only

0 Likes
461

HI

MODIFY will insert record if the row is not there in the table.

UPDATE will not insert record if the row is not there in the table. It will return sy-subrc to 4.

In UPDATE you can update specific fields using SET addition.

No it is not necessary to use UPDATE after MODIFY statement..

Also check these links

Regards

Pavan