‎2008 Mar 05 4:10 AM
hi everybody,
what is modify and update.
what is diffrence between them.
can you please give examples for both separately and compare them
‎2008 Mar 05 4:13 AM
Hi,
Check this..
Update Modify Insert stmts we use when we want to do some change / Insertion
(1) to database table from internal table or
(2) from work area to internal table.
( AA ) Update
If the intended record in the internal table is found in databse table means it will just update that record.
syntax to update database table from itab:::::
UPDATE dbtab FROM TABLE itab
Changes to lines made with the UPDATE command only becomefinal after a database commit
Without using internal table we can update database table directly as shown below:::::::::::::::::::::
TABLES SFLIGHT.
UPDATE SFLIGHT SET SEATSOCC = SEATSOCC + 3
WHERE CARRID = 'LH' AND
CONNID = '0400' AND
FLDATE = '19950228'.
( BB ) Modify is used to insert new record if the record doesnt exist in datbase table.system check this on primary key basis.
If the intended record in the internal table is found in databse table means it will just update that record.So here its equal to UPDATE stmt.
For changes to database table we use syntax as below ::::
MODIFY DatabaseTable FROM TABLE itab.
For changes to Internal table we use syntax as below ::::
MODIFY itab FROM wa INDEX idx.
http://TRANSPORTING f1 ... fn WHERE cond.
( CC ) Insert stmt is used to insert New records into databse table from internal table or to internal table from work area.
By default, data is only inserted in the current client. However, ifyou use the CLIENT SPECIFIED addition, you can switch off theautomatic client handling.
You cannot insert a table line if the table alreadycontains a record with the same primary key.
Syntax::::::::::
INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.
or
INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.
Example
Adding customer "Robinson" to client 002:
TABLES SCUSTOM.
SCUSTOM-MANDT = '002'.
SCUSTOM-ID = '12400177'.
SCUSTOM-NAME = 'Robinson'.
SCUSTOM-POSTCODE = '69542'.
SCUSTOM-CITY = 'Heidelberg'.
SCUSTOM-CUSTTYPE = 'P'.
SCUSTOM-DISCOUNT = '003'.
SCUSTOM-TELEPHONE = '01234/56789'.
INSERT INTO SCUSTOM CLIENT SPECIFIED VALUES SCUSTOM.
/message/4622903#4622903 [original link is broken]
Please reward points if helpful....
Gaurav J.
‎2008 Mar 05 4:13 AM
‎2008 Mar 05 4:13 AM
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.
'Insert' will add a new record or a new row into the database table.
'Update' will modify a record in the DB table.
'Modify' it is a combination of both insert and update...
Also check these links
UPDATE->
Bundling using Function Modules for Updates
If you call a function module using the statement CALL FUNCTION ... IN UPDATE TASK, the function module is flagged for execution using a special update work process. This means that you can write the Open SQL statements for the database changes in the function module instead of in your program, and call the function module at the point in the program where you would otherwise have included the statements. When you call a function module using the IN UPDATE TASKaddition, it and its interface parameters are stored as a log entry in a special database table called VBLOG.
The function module is executed using an update work process when the program reaches the COMMIT WORKstatement. After the COMMIT WORKstatement, the dialog work process is free to receive further user input. The update work process is responsible for the update part of the SAP LUW. The statement COMMIT WORKcloses the SAP LUW for the dialog part of the program and starts the update. The SAP LUW is complete once the update process has committed or rolled back all of the database changes. Bundling using function modules is called Update.
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/content.htm
MODIFY->
To modify the lines of a completed list from within the program, use the MODIFY LINE statement. There are two ways to specify the line you want to modify:
· Explicitly:
MODIFY LINE n OF CURRENT PAGE
modifications.
You can refer to the line most recently read:
MODIFY CURRENT LINE modifications.
This statement modifies the line most recently read by means of line selection (F2) or read by the READ LINE statement.
Apart from the ones described above, the modificationsaddition contains several other possibilities to modify the line. For more information on this and on the individual additions of the MODIFY LINEstatement , refer to the keyword documentation.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba4b235c111d1829f0000e829fbfe/content.htm
Check out the thread
Regards,
‎2008 Mar 05 4:15 AM
Hi friend,
MODIFY = UPDATE or INSERT
The statement UPDATE only changes an existing DB entry otherwise sy-subrc 0
The statement MODIFY updates an existing DB entry or, in no matching entry exists, inserts a new entry into the DB table.
Reward if useful.
Regards,
Swetha.
‎2008 Mar 05 4:18 AM
Hi,
Main difference:
MODIFY = UPDATE or INSERT
The statement UPDATE only changes an existing DB entry otherwise sy-subrc 0
The statement MODIFY updates an existing DB entry or, in no matching entry exists, inserts a new entry into the DB table.
Modify and Update:
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.
'Insert' will add a new record or a new row into the database table.
'Update' will modify a record in the DB table.
'Modify' it is a combination of both insert and update...
Also check these links
UPDATE->
Bundling using Function Modules for Updates
If you call a function module using the statement CALL FUNCTION ... IN UPDATE TASK, the function module is flagged for execution using a special update work process. This means that you can write the Open SQL statements for the database changes in the function module instead of in your program, and call the function module at the point in the program where you would otherwise have included the statements. When you call a function module using the IN UPDATE TASKaddition, it and its interface parameters are stored as a log entry in a special database table called VBLOG.
The function module is executed using an update work process when the program reaches the COMMIT WORKstatement. After the COMMIT WORKstatement, the dialog work process is free to receive further user input. The update work process is responsible for the update part of the SAP LUW. The statement COMMIT WORKcloses the SAP LUW for the dialog part of the program and starts the update. The SAP LUW is complete once the update process has committed or rolled back all of the database changes. Bundling using function modules is called Update.
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4bfa79e11d1950f0000e82de14a/content.htm
MODIFY->
To modify the lines of a completed list from within the program, use the MODIFY LINE statement. There are two ways to specify the line you want to modify:
· Explicitly:
MODIFY LINE n OF CURRENT PAGE
modifications.
You can refer to the line most recently read:
MODIFY CURRENT LINE modifications.
This statement modifies the line most recently read by means of line selection (F2) or read by the READ LINE statement.
Apart from the ones described above, the modificationsaddition contains several other possibilities to modify the line. For more information on this and on the individual additions of the MODIFY LINEstatement , refer to the keyword documentation.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dba4b235c111d1829f0000e829fbfe/content.htm
Check out the thread
Cheers,
vasavi.
kindly reward if helpful.
‎2008 Mar 05 4:30 AM
hI,
MODIFY - Will modify the table, if the data already exists, if NOT inserts new rows.
MODIFY for Database Tables
Inserts or changes lines in database tables.
Syntax
MODIFY <dbtab> FROM <wa>.
MODIFY <dbtab> FROM TABLE <itab>.
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.
MODIFY for any Internal Table
Changes the content of lines in internal tables of any type.
Syntax
MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2>...]
[ASSIGNING <FS> | REFERENCE INTO <dref>].
Copies the work area <wa> into the line of the internal table with the same table key as <wa>. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the modified line or the relevant data reference is stored in <dref> after the statement. You can use the TRANSPORTING addition to specify the exact components that you want to change.
UPDATE - Will update the table, errors out if the data is not found
UPDATE
Changes entries in database tables.
Syntax
UPDATE <dbtab> SET <si> = <f>
|<si> = <s i> + <f>
|<si> = <s i> - <f> [WHERE <cond>].
The value in the column <si> is set to the value <f>, increases it by <f>, or decreases it by <f> for all lines selected. The WHERE clause specifies the lines that are changed. If you omit the WHERE clause, all lines are changed.
Syntax
UPDATE <dbtab> FROM <wa>.
UPDATE <dbtab> FROM TABLE <itab>.
This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length and alignment as the lines of the database table.
Regards,
kavitha.
Edited by: kavitha koppada on Mar 5, 2008 5:31 AM
Edited by: kavitha koppada on Mar 5, 2008 5:32 AM
‎2008 Mar 05 4:30 AM
Hi,
MODIFY for Database Tables
Inserts or changes lines in database tables.
Syntax
MODIFY <dbtab> FROM <wa>.
MODIFY <dbtab> FROM TABLE <itab>.
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.
MODIFY for any Internal Table
Changes the content of lines in internal tables of any type.
Syntax
MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2>...]
[ASSIGNING <FS> | REFERENCE INTO <dref>].
Copies the work area <wa> into the line of the internal table with the same table key as <wa>. If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the modified line or the relevant data reference is stored in <dref> after the statement. You can use the TRANSPORTING addition to specify the exact components that you want to change.
MODIFY <itab> FROM <wa> TRANSPORTING <f1> <f 2>... WHERE <logexp>.
Copies the work area <wa> into the line of the internal table for which the logical expression is true. In each comparison of the logical expression, the first operand must be a component of the line structure.
MODIFY for Index Tables
Changes the content of lines in index tables.
Syntax
MODIFY <itab> FROM <wa> [INDEX <idx>] [TRANSPORTING <f1> <f 2>...]
[ASSIGNING <FS> | REFERENCE INTO <dref>].
Copies the work area <wa> into the line of the internal table with the index <idx>. If you omit the INDEX addition, you can only use the statement within a LOOP. In this case, you change the current loop line If you use ASSIGNING or INTO REFERENCE, field symbol <FS> refers to the modified line or the relevant data reference is stored in <dref> after the statement.
MODIFY for Lists
Changes a list line.
Syntax
MODIFY LINE <n> [INDEX <idx>] [OF CURRENT PAGE|OF PAGE <p>]
|CURRENT LINE
LINE FORMAT <option1> <option2>...
FIELD VALUE <f1> [FROM <g1>] <f2> [FROM <g2>]...
FIELD FORMAT <f1> <options1> <f2> <options2>.
Changes either line <n> on the current or specified list (or page), or the last line to be chosen. The exact nature of the change is specified in the additions
MODIFY SCREEN
Changes the SCREEN table.
Syntax
MODIFY SCREEN...
Like changing an internal table. The system table SCREEN contains the names and attributes of all of the fields on the current screen.
UPDATE
Changes entries in database tables.
Syntax
UPDATE <dbtab> SET <si> = <f>
|<si> = <s i> + <f>
|<si> = <s i> - <f> [WHERE <cond>].
The value in the column <si> is set to the value <f>, increases it by <f>, or decreases it by <f> for all lines selected. The WHERE clause specifies the lines that are changed. If you omit the WHERE clause, all lines are changed.
Syntax
UPDATE <dbtab> FROM <wa>.
UPDATE <dbtab> FROM TABLE <itab>.
This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length and alignment as the lines of the database table.
Regards,
Priya.