Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP SQL →  ABAP SQL - Write Accesses 

MODIFY dbtab

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


MODIFY target [connection] FROM source. 

Effect

The ABAP SQL statement MODIFY inserts one or more rows specified in source in the database table or classic view specified in target, or overwrites existing rows. The addition connection can be used to specify a secondary connection.

System Fields

sy-subrc Meaning
0 (means: When a work area was declared in source, the specified row was insertedor modified. When an internal table was specified in source, all specified lines were inserted, modified, or the internal table is empty.
2 (means: When a LOB handle structure was specified with a component forwriter streams, the non-LOBhandle components were not yet written to the database, but instead are passed when the stream is closed,at the latest. Whether this situation occurs or not depends on the database. See LOB handles.
4 (means: When a work area or a subquery was specified in source, no rows wereprocessed, or when an internal table was specified in source, not all specified rows were processed because there is already a row with the same uniquesecondary index in the database table.

The statement MODIFY sets sy-dbcnt to the number of processed rows. If an overflow occurs because the number or rows is greater than 2,147,483,647, sy-dbcnt is set to -1. If sy-subrc is 2, sy-dbcnt is also set to the value -1 (for undefined).


Notes

  • The changes are committed to the database by the next database commit. Until that point, they can still be undone using a database rollback The current isolation level defines whether the modified data can be read into other database LUWs before or only after the database commit.
  • The statement MODIFY sets a database lock as an exclusive lock until the next database commit or rollback. If used incorrectly, this can produce a deadlock.
  • The number of rows that can be inserted or modified in the tables of a database within a database LUW is limited, since a database system can only manage a limited amount of locks and data in the rollback area.
  • Once rows have been inserted in a global temporary table, this table must be emptied again explicitly before the next implicit database commit using the ABAP SQL statement DELETE FROM without WHERE or using an explicit database commit or database rollback. If not, the runtime error COMMIT_GTT_ERROR is produced.
  • The statement MODIFY dbtab FROM wa has the statement MODIFY itab FROM wa with identical syntax. If an internal table has the same name as a database table, a statement like this accesses the internal table.

Example

The first MODIFY statement inserts a row in an empty table. The second MODIFY statement modifies the values of the non-key fields of this row and inserts two additional rows.

DELETE FROM demo_update. 

MODIFY demo_update FROM @( 
  VALUE #(  id = 'X' col1 = 10 col2 = 20 col3 = 30 col4 = 40 ) ). 

MODIFY demo_update FROM TABLE @( 
  VALUE #( ( id = 'X' col1 =  1 col2 =  2 col3 =  3 col4 =  4 ) 
           ( id = 'Y' col1 = 11 col2 = 12 col3 = 13 col4 = 14 ) 
           ( id = 'Z' col1 = 21 col2 = 22 col3 = 23 col4 = 24 ) ) ). 

Continue

MODIFY dbtab - source

MODIFY FROM TABLE