MODIFY dbtab - source

Syntax

... FROM { {wa} | {TABLE itab} }.

Alternatives:

1. ... FROM wa

2. ... FROM TABLE itab

Effect

A wa data object that is not table-type or an itab internal table can be specified after FROM. On the one hand the content of the data objects determines whether the line(s) are inserted or changed, and on the other hand, which values are inserted or used for changes.

Alternative 1

... FROM wa


Effect

When a wa work area that is not table-type is specified, which meets the requirements for use in Open SQL statements, a line 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 line is not found, a new line is inserted according to the same rules as for the INSERT statement.

If such a line is found, this line 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, then it is not executed and sy-subrc is set to 4.

Notes

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, it will be 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 lines in the internal table according to the rules for the wa work area. The line type of the internal table has to meet the requirements for use in Open SQL statements.

If the change to a line in the internal table would lead to a double entry in a unique secondary index, the corresponding line is not inserted and sy-subrc is set to 4. If the internal table is empty, sy-subrc is set to 0. The sy-dbcnt system field is always set to the number of lines that were actually processed.