7

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.

Arpit
  • 6,212
  • 8
  • 38
  • 69
Rohit Sinha
  • 71
  • 1
  • 1
  • 2

4 Answers4

9

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@

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
René
  • 2,912
  • 1
  • 28
  • 46
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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
parachute
  • 11
  • 1
0

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?

Community
  • 1
  • 1
knut
  • 27,320
  • 6
  • 84
  • 112
-1

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

Achuth hadnoor
  • 332
  • 4
  • 16