MODIFY statement used to modify the data in the table. MODIFY statement used as a combination of INSERT and UPDATE statement.

If the database table contains no row with the same key, the row gets inserted, MODIFY works like INSERT in this case and the row is added. If the database already contains a row with the same key, the row gets updated, MODIFY works like UPDATEin this case and the line is changed.

We can add or change one or more rows in a database table db-table. We can only insert or change rows in an ABAP Dictionary view if it is defined on one table and its maintenance status is defined as Read and change.

We can specify the database table db-table either statically or dynamically. Modifying data can be performed in two ways and those are -

  • Modify single record using table work area
  • Modifying several lines using internal table

Modify single row using table work area -

To insert or modify a single row in a database table, use the following syntax -

MODIFY db-table FROM work-area.

db-table is the name of a ABAP Dictionary database table and work-area is the table work area.


The work area work-area data are written to the database table db-table. The work area work-area should be same type, length and alignment as the database table structure. The data is placed in the database table according to the table structure row, and regardless of the work area structure. It is always a good idea to define the work area with reference to the database table structure.

If the database table does not already contain a row with the same key as specified in the work area, a new line is inserted. If the database table does contain a row with the same key as specified in the work area, the existing row is overwritten. SY-SUBRC is always set to 0.

Modifying multiple rows using internal table -

To insert or change multiple rows in a database table, use the following syntax -

MODIFY db-table FROM TABLE internal-table.

db-table is the name of a target database table and internal-table is the name of the source internal table.


The internal table internal-table lines that are not already a row in the database table with the same key are inserted into the table. Those lines of the internal table internal-table that are already a row in the database table with the same key overwrite the existing row in the database table.

SY-SUBRC is always set to 0. SY-DBCNT is set to the number of lines in the internal table.


Example -

The below example to modify the below IFB product information into the table ZTC_TPRODUCT.

PRODUCTIDPRODUCTPRODUCT PRICE
IFB4 IFB dishwasher36000

Code -

*&---------------------------------------------------------------------*
*& Report  Z_OPENSQL
*&---------------------------------------------------------------------*
*& Written by TutorialsCampus
*&---------------------------------------------------------------------*

REPORT  Z_OPENSQL.

TABLES ZTC_TPRODUCT.
DATA: WA LIKE ZTC_TPRODUCT.

*Assigning new data for the IFB4 product
WA-PRODUCTID = 'IFB4'.
WA-PRODUCT   = 'IFB dishwasher'.
WA-PRODUCT_PRICE   = 50000.

*Modifying table with Work area.
MODIFY ZTC_TPRODUCT FROM WA.

*Error handling
IF SY-SUBRC <> 0.
  WRITE: 'Data not Mofified, Return code is: ', SY-SUBRC.
ELSE.
  WRITE 'Data Modified/inserted successfully..'.
ENDIF.

Output -

MODIFY statement example output
Table Data After MODIFY -
MODIFY statement example output