Custom table primary key changed

1.4k Views Asked by At

I have created a custom table as a data dictionary object in SE11. I have the following fields :

  • ID (KEY Field )
  • NAME (KEY Field )
  • DEP (KEY Field )
  • DESIGNATION

I have activated the table and also generated a table maintenance generator but after some time, I think Field DEP is not required as a key field so I unchecked it as a key field and then again I try to activate my table I am getting this error :

error_tb_primary_key_changed

2

There are 2 best solutions below

0
On

There another table with a foreign key reference to Z_EMP_2410. When this is the case, you are prevented from changing a primary key. Remove this foreign key or keys from Z Tables first. Then try re-Activate the Z_emp_2410 again. Once Z_emp_2410 is activated, you can re-add the foreign key/s in Table z_? pointing to Z_EMP_2410 if it is still appropriate.

0
On

There are entries already in the table and if you set a key field as not a key field, the data in the table might not be consistent anymore.

In this case most likely there are several entries with the same ID and NAME, but different DEP. After setting DEP as not a key field, this would not be possible anymore. The table entries have to be cleaned up, so there is only one entry for the same ID and NAME. After that it will be possible to set DEP as not key field. (After that don't forget to regenrate the maintenence view as well.)