开发者

Update Statement in ABAP not working

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.


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@


After using UPDATE, if sy-subrc = 4, then at least one line was not able to be changed, either because no appropriate line was found, or because the change would generate a line that leads to double entries in the primary key or a unique secondary index in the database table.

The statement UPDATE sets sy-dbcnt to the number of changed lines.


You can't 'change' key fields in data bases. You may delete your original entry and insert a new one with another key. But you can't change a key field. (I can't check actual, if modify is doing it on it's own.

If you have to change a key field, you should think about your DB-definition.

More about changing key fields: Can we update primary key values of a table?


hi i tried to create the table with your keys as mentioned , I advice you to use the below syntax

update lt_zicstt099 set email_id = 'some value' where WEB_USER_ID = 'some web id'.

To check if the table is updated you can use sy-dbcnt to know the number of lines updated. if still you face issues please comment below

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜