ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Write Accesses → MODIFY dbtab
MODIFY FROM TABLE
This example demonstrates the statement MODIFY
...
FROM TABLE
.
Other versions:
7.31 | 7.40 | 7.54
Source Code
DELETE FROM demo_bulk_modify. "has an unique secondary index k1, v1
INSERT demo_bulk_modify FROM @( VALUE #( k1 = 1 k2 = 1 v1 = 1 ) ).
DATA itab TYPE STANDARD TABLE OF demo_bulk_modify WITH EMPTY KEY.
itab = VALUE #( ( k1 = 1 k2 = 2 v1 = 1 )
( k1 = 1 k2 = 1 v1 = 2 ) ).
MODIFY demo_bulk_modify FROM TABLE itab. "platform dependent!
SELECT *
FROM demo_bulk_modify
INTO TABLE @DATA(result).
cl_demo_output=>display( result ).
Description
The database table DEMO_BULK_MODIFY has two key fields, K1
and K2, and a normal field V1. A unique
secondary index IDX comprises the fields K1
and V1. The database table is filled with a row 1, 1, 1, and then the
statement MODIFY ... FROM TABLE
is used with an internal table with the rows 1, 2, 1 and 1, 1, 2. The result is platform-specific:
- In database systems with row-by-row
MODIFY
, like the SAP HANA database, the first row of the internal table cannot be inserted because of the unique secondary index. The second row of the internal table overwrites the existing row and the result is a row with the content 1, 1, 2.
- In database systems with row-by-row
MODIFY
and termination after a failed insert, such as SAP MaxDB, no change is made and the result is a row with the content 1, 1, 1.
- In database systems with block-by-block
UPDATE
andINSERT
, such as ORACLE DB, the existing row is overwritten with the second row of the internal table and then the first row of the internal table is inserted; the result is two rows 1, 1, 2 und 1, 2, 1.