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 SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software


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 Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/primary-key-change-not-permitted-for-value-table.aspx)
Check Existence using ABAP SELECT
ABAP LOOP Statement with At New and At End
How to Debug Popup Screen in ABAP
How to Spell Numbers using ABAP Spell_Amount Function Module
Create Business Object in SAP
Delete All Data from SAP Database Table
How to Upload Data to SAP from Excel File using alsm_excel_to_internal_table Function Module
ABAP - Create Hierarchy Tree List using rs_tree_construct, rs_tree_list_display and snodetext
ABAP Tutorial - ABAP String Split Example Code
Upload Data from Excel File in ABAP using TEXT_CONVERT_XLS_TO_SAP
Create CL_GUI_ALV_GRID ALV Grid Column Header using ABAP Data Element
How to Create SAPScript Text using SO10 Transaction Code
Sales Tables among ABAP Tables (SAP Sales and Distribution SD Tables)
ALV Grid Color - Table Row Background Color in ALV List
SAP ABAP Tutorial - ALV Grid Example with cl_gui_alv_grid and Screen Painter
SAP Payment Terms Table and ZTERM Texts Table for ABAP Developers
SAP Smartforms - How to Call Smartform within ABAP Program
ABAP Tutorial - SAP Split and ABAP Split String Function
SAP Tutorial - Convert Spool Request to PDF File using RSTXPDFT4 ABAP Report
Set Default Single Values List for SAP Selection Screen Parameter
ABAP Debugging using Log Point and Break Point
ABAP RegEx for ABAP Regular Expression to fetch Date from String
ABAP Runtime Error ST22 Transaction using Short Dump Analysis
ABAP Shared Memory Objects Tutorial with Sample ABAP Code
ABAP Try Catch for exception is neither caught Code Inspector Error
Add Year, Month or Day to Date Variable in ABAP using RP_CALC_DATE_IN_INTERVAL
Read Address Data using FM ADDR_GET instead of Querying ADRC Table
ABAP Authority-Check Object For User Other Than Current
SAP Code Inspector for ABAP Break-Point Statement
Call Function Module using RFC Destination in ABAP
CALL_FUNCTION_NOT_FOUND ABAP Run Time Error
Convert the table using the Database Utility (SE14)
Convert Sales Unit into Text using Function Module in Target Language
Create SAP Dynamic Variant using Date Calculation
Create SAP Transaction to Maintain ABAP Table using SM30
Database Hint Pseudo-Comment for SAP Code Inspector
Delete Entries in NAST Table using RSCLNAST ABAP Program
Dynamic Programming using Field Symbols in ABAP Reports
Prevent DYNPRO_SEND_IN_BACKGROUND Error in Background Process
Execute ABAP Program Automatically After Transport Request Import
How to Execute SAP Program in Background Task
How to Find Internal Table Row Count in ABAP
Export SAP Data to Fixed Length Text File
Get Fullname of SAP user using Function Module in ABAP Program
How to Find User Exits in ABAP Codes of SAP Transaction
Read Integer and Decimals of a Numeric Value in ABAP Programming
Invoice Output fail because of missing Billing Type text in TVFKT table
Move Minus Sign from Right to Left of Negative Number in SAP Smartform
Primary key change not permitted for value table
Read Pricing Condition Text using ABAP in SAP Sales Document Output
Read Text Symbols in Specific Language using ABAP RS_TEXTPOOL_READ
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
SAP Purchase Order Tables, Transaction Codes and Output
Export Table Contents into Text File and Download File
Search and Find SAP Transaction Code using SE93 or SEARCH_SAP_MENU
SAP Code Inspector Error: Select For Cluster Table Without Order By
ABAP Select Statement using Space instead of Null or Initial
SAP Code Inspector: Select-Statement can be Transformed
ABAP Tutorial for SET and GET PARAMETER ID Command
ABAP CONVT_NO_NUMBER Error on SP01 due SP01_WARN Parameter
How to find string length using STRLEN ABAP string function
ABAP Submit Report to Run Another ABAP Program within Code
Transport Variants of an ABAP Program into Workbench Request
TVAP Item Category and SAP Table TVAPT for Text Translations
Code Inspector: Unsecure use of FOR ALL ENTRIES
Update Multiple Variables in ABAP Select Single Statement
Update Database Table Data using ABAP SE16N_INTERFACE
Function module is not released for the Internet
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement
Activate Fixed Point Arithmetic Flag for Open SQL Statement


Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems