Update Statement in ABAP not working

Rohit Sinha picture Rohit Sinha · Aug 30, 2011 · Viewed 18.5k times · Source

I have an UPDATE statement in ABAP which looks like :

UPDATE zicstt099 FROM TABLE lt_zicstt099

The Update is failing every time with sy-subrc eq 4.

The database Table ZICSTT099 has three primary keys : WEB_USER_ID & EMAIL_ID along with MANDT field.

I am trying to change the EMAIL_ID value but the same is not getting Updated.

Kindly help.

Answer

René picture René · Aug 30, 2011

You cannot change primary key fields using the UPDATE <target> FROM <wa>. and UPDATE <target> FROM TABLE <itab>. statements, since they use the primary key to lookup the record(s) they must update.

Use the UPDATE <target> SET <set1> ... WHERE ... statement instead.

You can find the specifics over here: https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapupdate_source.htm#!ABAP_ALTERNATIVE_1@1@