ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP - Database Accesses → Open SQL → Open SQL - Write Accesses → MODIFY dbtab
MODIFY dbtab - source
Other versions: 7.31 | 7.40 | 7.54
Syntax
... FROM wa|{TABLE itab}.
Alternatives
1. ... FROM wa
2. ... FROM TABLE itab
Effect
A wa
data object that is not table-like or an itab
internal table can be specified after FROM
. The content of the data objects
determines whether the row(s) are inserted or changed as well as which values are inserted or used for changes.
Alternative 1
... FROM wa
Effect
When a wa
work area is specified that is not table-like and meets the
prerequisites for use in Open SQL statements, a row is searched for in the database table that has the same content in the
primary key as the corresponding beginning part of the work area.
If such a row is not found, a new row is inserted according to the same rules as for the INSERT
statement.
If such a row is found, it is overwritten according to the same rules as for the UPDATE
statement.
If the change would lead to a double entry in a unique secondary index, it is not executed and sy-subrc
is set to 4.
Automatic client handling is performed by default, which means that a
client identifier
specified in wa
is not taken into account; the current client is used instead.
The content of wa
is not affected. You can deactivate automatic client handling with addition CLIENT SPECIFIED
.
Notes
-
The
wa
work area should always be declared with reference to the database table or the view in the ABAP Dictionary. For the derivation of lob handle structures, there are special additions to statementsTYPES
and[CLASS-]DATA
. -
If the database table or view is specified statically, the specification of the work area using
FROM wa
can be omitted both outside of classes and for one short form if adbtab
table work area is declared for the corresponding database table or for the view using theTABLES
statement. The system supplements theMODIFY
statement implicitly to include theFROM dbtab
addition.
Example
Create or change a message in database table T100. If there is no message with the number 100 in the MYMSGCLASS message class in English, this is created. Otherwise, only the text is changed.
DATA message_wa TYPE t100.
message_wa-sprsl = 'EN'.
message_wa-arbgb = 'MYMSGCLASS'.
message_wa-msgnr = '100'.
message_wa-text = 'Some new message ...'.
MODIFY t100 FROM message_wa.
Alternative 2
... FROM TABLE itab
Effect
If an itab
internal table is specified, the system processes all rows in the internal table according to the rules for the wa
work area. However, if an internal table is specified,
locators are used as the source but cannot generate
writer streams.
The row type of the internal table must fulfill the prerequisites for use in Open SQL statements.
If the change to a row in the internal table would lead to a double entry in a unique secondary index,
the corresponding row is not inserted and sy-subrc
is set to 4. If the internal
table is empty, no rows are processed and sy-subrc
is set to 0. The sy-dbcnt
system field is always set to the number of rows that were actually processed.