2007 Oct 04 1:46 PM
Hi All,
I am updating a database table from an internal table.
I am changing the non-key fields in that table.
when I check sy-subrc = 4.
Record already exists, because I am changing non-key fields of the
database table.
Is there any addition like to accept the duplicate keys with update.
Alternatively, I have used Modify, It is adding new record,
Again, I have search the old record and use Delete on the database table.
Thanks & Regards,
Kalyan Chandramouli
SAP ABAP Consultant
2007 Oct 04 2:18 PM
It seems that you changed key fields, else MODIFY wont create new records?
Look at your Z-table (I hope this is a Z-table, no?) is there an alternative index with unique key?
Regards
2007 Oct 04 2:18 PM
2007 Oct 04 2:25 PM
HI,
You can use the UPDATE statment, but as we know, if the key fields are same then it will update that record, if the key fields are not same then it will add a record to the database table
Regards
Sudher
2007 Oct 04 3:09 PM
Hi,
You are right, the field which I am trying to change is a part of primary key.
Because, sy-subrc = 4. says,
No line with specified primary key exits in the database table.
I have a Z-tabel, with Kunnr Vkorg Matnr Bzirk Bztxt Split_percentage
In this table primary key consists of KunnrVkorgMatnr+Bzirk.
I am able to change the Split_percentage using UPDATE.
Now, my client want to change Bzirk, Bztxt also in the table.
How can I Go.
Thanks & Regards,
Kalyan Chandramouli
SAP ABAP Consultant
2007 Oct 04 3:16 PM
2007 Oct 05 7:19 AM
hi
This is the way to update ur Table in this Scenario.
From internal table to DB table.
data : itab type table of <ur Ztable> with header line.
<<Fill the Data into the itab>> . "Key fields must also be filled
UPDATE <ZTABLE> FROM TABLE ITAB .
REWARD IF HELPFUL.
2007 Oct 04 4:11 PM
Using Update we can change only non-key fields,
Kalyan Chandramouli
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |