‎2007 Sep 17 8:21 AM
Modify can play the role of either the Append or Insert depending on the type of the table.
How would modify play the role?
‎2007 Sep 17 8:39 AM
Hi,,
Hi,
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.
Regards,
nagaraj
‎2007 Sep 17 8:31 AM
Hi,
Works like INSERT for database tables if there is not yet a line in the table with the same primary key.
Works like UPDATE if a line already exists with the same primary key.
Regards,
Bhaskar
‎2007 Sep 17 8:32 AM
Hi,
if you use modify statement it either:
inserts a record in a table when no record already exists with same key(hence insert role)
else it modify an already existing record with same key.
Regards,
Revert back in case of doubts.
‎2007 Sep 17 8:32 AM
Hello there,
It is not like that, Modify can play the role of Update and Insert(can be append in standard tables) according to the situtation. If you use modify It will look for the entry matching with the key, If there is an entry found it will update other fields of the table entry found with the values you have provided before the modify statement, And if there is no entry found it will insert(or append) a new record to the table depending on the situation.
Reward points if helpful.
Regards
Tharanatha
‎2007 Sep 17 8:39 AM
Hi,,
Hi,
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.
Regards,
nagaraj