Open SQL – Writes Statements

Writes include inserting, modifying, and deleting content in database tables. All writes can be made as individual accesses or as mass access. If multiple rows of a database table are to be changed, mass access using internal tables generally gives better performance than individual accesses. 

  • INSERT
  • UPDATE
  • MODIFY
  • DELETE

INSERT { {INTO target VALUES wa } | { target FROM wa|{TABLE itab} } }. 

INSERT INTO scarr VALUES @scarr_wa. 
INSERT scarr FROM @wa.
INSERT scars FROM TABLE @itab.

System Fields
The statement INSERT sets the values of the system fields sy-subrc and sy-dbcnt.

The INSERT statement sets sy-dbcnt to the number of rows inserted. 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). 

UPDATE { {SET set_expression1, set_expression2, … [WHERE sql_cond]}
| {FROM wa|{TABLE itab}} }. 

UPDATE scustom FROM @wa. 
UPDATE scustom FROM TABLE @itab.

System Fields
The statement UPDATE sets the values of the system fields sy-subrc and sy-dbcnt. 

MODIFY … FROM wa|{TABLE itab}. 

MODIFY t100 FROM @message_wa. 
MODIFY t100 FROM TABLE @itab.

System Fields
The statement MODIFY sets the values of the system fields sy-subrc and sy-dbcnt. 

DELETE { {FROM target [WHERE sql_cond]} | {target FROM source} }. 

DELETE FROM sflight WHERE carrid = @p_carrid AND fldate = @sy-datum AND seatsocc = 0. 
DELETE FROM sflight FROM @wa.
DELETE FROM sflight FROM TABLE @itab.

System Fields
The statement DELETE sets the values of the system fields sy-subrc and sy-dbcnt. 

sy-subrcMeaning
0When a work area was declared in source, the specified row was changed. In the declaration of an internal table in source, all declared rows were inserted, or the internal table is empty.
2When a LOB handle structure was specified with a component for writer streams, the non-LOB handle 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. Refer to LOB handles.
4When a work area was specified in source, the declared row was not inserted, or, when an internal table was specified in source, not all declared rows were inserted, since a row in the database table has the same primary key or a unique secondary index.

source: abapdocu

Leave a Reply