You are on page 1of 2

MODIFY is the open SQL statement to insert or change entries in the database table.

If the database table contains no line with the same primary key as the line to be inserted, MODIFY works like INSERT, that is, the line is added. If the database already contains a line with the same primary key as the line to be inserted, MODIFY works like UPDATE, that is, the line is changed. The syntax for the MODIFY statement is as follows. MODIFY <database table> FROM <work area> If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.
DATA: gwa_employee TYPE zemployee. gwa_employee-id gwa_employee-name gwa_employee-place gwa_employee-phone gwa_employee-dept_id = = = = = 6. 'JOSEPH'. 'FRANKFURT'. '7897897890'. 5.

MODIFY zemployee FROM gwa_employee.

ZEMPLOYEE table entries before MODIFY

ZEMPLOYEE table entries after MODIFY

Since there was no entry with the key 6, a new entry was added to the table.
DATA: gwa_employee TYPE zemployee.

gwa_employee-id gwa_employee-name gwa_employee-place gwa_employee-phone gwa_employee-dept_id

= = = = =

6. 'JOHNNY'. 'LONDON'. '7897897890'. 3.

MODIFY zemployee FROM gwa_employee.

Since there was an entry with the key 6, the values in the existing record were modified.

You might also like