SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Primary key change not permitted for value table

When I add MANDT field as primary key in ABAP table, I get Primary key change not permitted for value table error. This ABAP tutorial shows how to add MANDT field as primary key to an ABAP value table which is defined as a check table. In this tutorial, ABAP developers will find hints for how to find foreign keys using Where-Used List and delete foreign keys.

ABAP programmers can experience similar problems while defining a non key field as a key field on an ABAP transparent table.

Primary key change not permitted for value table ZTR_PFORM_H
Message no. AD300

Diagnosis
This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.

System Response
Procedure
If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.

To regenerate the same error I experienced I can list the steps one by one in order as follows:

Call SE11 transaction code to change table structure of a custom table in data dictionary.
Switched to change mode and display Fields tab.
Then click on first field VBELN on the list and click Insert Row icon to add the new table field.
Type MANDT as field name with data element MANDT. Mark the Key and Initial Values checkboxes.
Save and Activate

add MANDT field in custom table in ABAP

Unfortunately I got following error message

errors occured when activating ABAP dictionary object

The details of the error log can be viewed in activation of worklist.

errors occured when activating ABAP dictionary object

The help message for the activation error log is as follows:

This table is defined as a check table

How to resolve this error

Call transaction SE11.
Type the custom table name in database table input field. Check option box before it.
Click on Where-Used List icon

Where Used List in SAP SE11 transaction

Be sure that you have marked the Domains, Data elements, Structures, Database Tables, Views, etc for the search in WHERE Used List of custom ABAP database table

ABAP database table Where Used List

I had previouslt find SAP Web Dynpro components using this ABAP table in data context nodes and map those context to a copy of this ABAP table. Of course before this I created the empty copy of the database table by using the Copy button on SE11 tcode. But only removing the Web Dynpro did not help me for the solution.
After adding database tables to the Where Used List search, finally I could find an entry which prevents me to add MANDT field as primary key to my custom ABAP table and activate this ABAP data dictionary object.

Where Used database table

Display ABAP table structure in SE11 transaction and switch to change mode. Since the activation error indicated that table is defined as a check table, go to Entry help/check tab. You will see the table name that I want to add MANDT field as primary key in the check table column.

check table in ABAP transparent table

As seen above, this check table definition for PROFORMA_NR field is preventing me to add MANDT field to my database table and mark as primary key.
To delete this check table display referencing ABAP table in change mode using SE11 SAP transaction.
Navigate to Fields tab
Highlight related ABAP table field.
Click on Foreign Keys icon on the icons row right above the field list.
When Change Foreign Key dialog screen is displayed on screen as below, click on DELETE icon to remove the foreign key definition temporarily to add back later. Save table definition and activate it.

remove foreign key temporarily on ABAP table field

After foreign key definition on ABAP table where check table entry for our original table is deleted go back to source table.
Open database table in change mode using SE11 tcode.
Add MANDT field, mark as primary key. SAVE database table's new structure and activate ABAP table.
This time SAP transparent table is successfully activated without a problem.

Please note that I faced this problem on an empty database table on which I was making my ABAP developments.
There were no rows created in the ABAP database table. So adding MANDT field as primary key could be solved only by deleting foreign keys referencing the table.
If there are records inserted into the database table, one additional step is to call SAP transaction SE14 ABAP Dictionary: Database Utility and Activate and adjust database with "Save data" option.
Adjust table will add missing MANDT field values and provide data consistency within the database table.

To summarize, if an ABAP developer is trying to add a new column like MANDT as a primary key to an existing SAP custom table, he can experience the error: "Primary key change not permitted for value table". The underlying reason for preventing primary key change is that the table is defined as a check table and there are foreign keys created refering this ABAP table.

The solution is to identify where this ABAP table is used in ABAP Data Dictionary objects like tables, etc. After you identify where this table is used, remove referencing check table entries or foreign keys.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.