1. MODIFY dbtab FROM
wa. or
MODIFY (dbtabname) FROM wa.
2. MODIFY dbtab FROM
TABLE itab. or
MODIFY (dbtabname) FROM TABLE itab.
3.
MODIFY dbtab. or
MODIFY *dbtab.
4. MODIFY dbtab
VERSION vers. or
MODIFY *dbtab VERSION vers.
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 variable dbtabname in the form
MODIFY (dbtabname) .... In both cases, the database table
must be defined in the ABAP Dictionary. If the program contains the name of the database table, it must
also have a corresponding TABLES
statement. 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.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Open SQL and Unicode.
The system field SY-DBCNT contains the number of lines
processed after the call of the statement.
The Return Code is set as follows:
MODIFY dbtab FROM wa. or
MODIFY (dbtabname) FROM wa.
1. ... CLIENT
SPECIFIED
2. ... CONNECTION con
Inserts a new line or updates an existing line in a database table. The primary key
for identifying the line to be inserted or updated and the relevant values are taken from the work area
wa. When doing this, the data is read from wa
from left to right according to the line structure of the database
table
dbtab. Since the structure of wa is not taken
into account, the work area wa must be at least as wide
(see DATA) as the line structure
of dbtab, and the alignment
of the work area wa must correspond to that of the line
structure. Otherwise, a runtime error occurs.
If the database table
dbtab or the work area wa
contains strings, then wa
must be compatible with the line structure of dbtab.
Insert or change data of the customer Robinson in the current client:
DATA: wa TYPE scustom.
wa-id = '12400177'.
wa-name =
'Robinson'.
wa-postcode = '69542'.
wa-city = 'Heidelberg'.
wa-custtype = 'P'.
wa-discount = '003'.
wa-telephone = '06201/44889'.
MODIFY scustom FROM wa.
... CLIENT SPECIFIED
Switches off automatic client handling. This allows you
to edit data across all clients
even when dealing with client-specific tables. The client field is treated like a normal table field
that must be programmed to accept values in the work area wa.
The addition CLIENT SPECIFIED must be specified immediately after the name of the database table.
... CONNECTION con
The Open SQL command is not executed on the
standard database, but on the secondary
database connection
specified with con. con
is the name of the databse connection as it was specified in the table DBCON
in the column
CON_NAME. The database connection con can also
be specified dynamically in the form (source_text), where
the field source_text contains the name of the database
connection and must be type
C or STRING.
The CONNECTION con addition must be specified directly
after the name of the database table or after the CLIENT SPECIFIED addition.
MODIFY dbtab FROM TABLE
itab.or
MODIFY (dbtabname) FROM TABLE itab.
1. ... CLIENT
SPECIFIED
2. ... CONNECTION con
Mass modify: Inserts new lines or updates existing lines of a database table. The primary keys for identifying
the lines to be inserted or updated and the relevant values are taken from the internal table
itab. The lines of the internal table itab
must satisfy the same conditions as the work area wa in addition 1 to variant 1.
If the internal table itab is empty, SY-SUBRC and SY-DBCNT are set to 0.
... CLIENT SPECIFIED
As with variant 1.
... CONNECTION con
As with variant 1.
MODIFY dbtab. or
MODIFY *dbtab.
1. ... CLIENT
SPECIFIED
2. ... CONNECTION con
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot
Use Short Forms and Cannot Use *-Work Areas.
This variant is obsolete.
These are the SAP-specific short forms of variant 1. They have the same effect as variant 1, but you
do not specify the work area explicitly. Instead, the system implicitly uses the table work
area dbtab or *dbtab
declared using the TABLES statement.
is therefore equivalent to
Add or change the data of customer Robinson in the current client:
TABLES scustom.
scustom-id = '12400177'.
scustom-name =
'Robinson'.
scustom-postcode = '69542'.
scustom-city =
'Heidelberg'.
scustom-custtype = 'P'.
scustom-discount = '003'.
scustom-telephone = '06201/44889'.
MODIFY scustom.
If you do not explicitly specify a work area, the values for the line to be inserted or updated are
taken from the table work area dbtab even if the statement
is included in a
FORM or FUNCTION in which the table work area is hidden by a formal parameter or a local variable of the same name.
... CLIENT SPECIFIED
As with variant 1.
... CONNECTION con
As with variant 1.
MODIFY dbtab VERSION vers. or
MODIFY *dbtab VERSION vers.
This variant is not allowed in an ABAP Objects context. See Cannot Use the VERSION Addition.
This variant is obsolete.
Inserts a new line or updates an existing line in a database table, the name of which is taken from
the field vers at runtime. If no line exists with the
specified primary key, an INSERT is executed. Otherwise,
an UPDATE is performed. The database table must be defined
in the ABAP/4 Dictionary and its name must conform to the naming conventions for R/2 ATAB tables. These
stipulate that the name must begin with 'T' and may contain up to four further characters. The field
vers must contain the table name without the leading 'T'.
Only lines in the current client are inserted or updated. The line to be inserted is taken from the
statically specified table work area
dbtab or *dbtab.
SY-SUBRC is set to 0 if the line is successfully
inserted or updated. SY-SUBRC <> 0 is not possible since any other result causes a runtime error.
... CLIENT SPECIFIED
As for variant 1.
Inserting or Changing Linesin Tables