Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update Statement in ABAP not working

Tags:

abap

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.

like image 872
Rohit Sinha Avatar asked Aug 30 '11 03:08

Rohit Sinha


People also ask

How to use UPDATE statement in SAP ABAP?

The statement UPDATE sets sy-dbcnt to the number of changed rows. If an overflow occurs because the number or rows is greater than 2,147,483,647, sy-dbcnt is set to -1. If sy-subrc is 2, sy-dbcnt is also set to the value -1 (for undefined). The changes are committed to the database by the next database commit.

How do you write a modify statement in SAP ABAP?

The MODIFY statement inserts one or more rows specified in source in the database table or classic view specified in target, or overwrites existing rows. The statement MODIFY sets the values of the system fields sy-subrc and sy-dbcnt. When a work area was declared in source, the specified row was inserted or modified.

How do I UPDATE a custom table in SAP?

You can use update/modify statements. UPDATE dbtab SET f1 = value1 where condition. UPDATE dbtab FROM TABLE itab. Here from itab internal table, you can update the ztable.


1 Answers

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@

like image 147
René Avatar answered Oct 07 '22 01:10

René