Stop googling SAP errors. Use our Free Essentials plan instead - no credit card needed. Start Now

Close

How To Fix VK859 - Foreign key cannot be created for the selected field &1-&2


SAP Error Message - Details

  • Message type: E = Error

  • Message class: VK - Pflege und Bearbeitung von Konditionen

  • Message number: 859

  • Message text: Foreign key cannot be created for the selected field &1-&2

  • Show details Hide details
  • What causes this issue?

    In order to check a field or to display possible entries, the system
    requires a foreign key dependency.
    The system cannot create the foreign key dependency for field &V1&-&V2&
    .
    The system needs other fields to check the above field. However, in
    this case, the required field is missing. A check cannot be carried
    out.

    System Response

    The system allows a missing foreign key dependency but this is
    detrimental to the functionality.

    How to fix this error?

    Please contact your system administrator if you cannot make the
    required settings.

    Error message extract from SAP system. Copyright SAP SE.


Smart SAP Assistant

  • What is the cause and solution for SAP error message VK859 - Foreign key cannot be created for the selected field &1-&2 ?

    The SAP error message VK859 indicates that a foreign key relationship cannot be created for the specified fields in the context of a table or data structure. This error typically arises when there is an attempt to establish a foreign key constraint between two fields, but certain conditions are not met.

    Causes of VK859

    1. Data Type Mismatch: The fields you are trying to link as foreign keys may have different data types or lengths. For example, one field might be defined as CHAR(10) while the other is CHAR(20).

    2. Field Attributes: The attributes of the fields (like whether they are nullable or not) may not be compatible. For instance, if one field is defined as NOT NULL and the other allows NULL values, this can cause issues.

    3. Existing Data: If there is existing data in the tables that would violate the foreign key constraint, the system will not allow the creation of the foreign key.

    4. Primary Key Issues: The referenced field in the parent table must be a primary key or have a unique constraint. If it does not, the foreign key cannot be established.

    5. Table Locking: If the table is locked or in use by another transaction, it may prevent the creation of the foreign key.

    Solutions

    1. Check Data Types: Ensure that both fields have the same data type and length. If they do not match, you may need to adjust the field definitions.

    2. Review Field Attributes: Make sure that the attributes of both fields are compatible. If one field is NOT NULL, ensure that the corresponding field in the parent table is also NOT NULL.

    3. Validate Existing Data: Check the existing data in both tables to ensure that there are no records in the child table that do not have corresponding records in the parent table. You may need to clean up the data before creating the foreign key.

    4. Ensure Primary Key: Verify that the field in the parent table that you are referencing is a primary key or has a unique constraint.

    5. Check for Locks: Ensure that the tables are not locked by other transactions. You can use transaction codes like SM12 to check for locks.

    6. Use Transaction Codes: Use transaction codes like SE11 (Data Dictionary) to check the definitions of the tables and fields involved.

    Related Information

    • Foreign Key Constraints: Foreign keys are used to maintain referential integrity between tables. They ensure that a record in one table corresponds to a valid record in another table.

    • Data Dictionary (SE11): This transaction allows you to view and modify the definitions of database objects, including tables and fields.

    • Database Consistency: Maintaining consistency in your database is crucial. Foreign key constraints help prevent orphaned records and ensure that relationships between tables are valid.

    • SAP Notes: Check SAP Notes for any specific issues or patches related to this error message, as there may be known issues or updates that can help resolve the problem.

    By following these steps and understanding the underlying causes, you should be able to resolve the VK859 error and successfully create the foreign key relationship.

    • Do you have any question about this error?


      Upgrade now to chat with this error.


Instant HelpGet instant SAP help. Sign up for our Free Essentials Plan.


Related SAP Error Messages

Click the links below to see the following related messages:
  • VK858 Screen &1 &2 generated
    Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...

  • VK857 Report & generated
    Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...

  • VK860 Screen &1 &2 saved
    Self-Explanatory Message Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of...

  • VK861 System error: maximum number of tables (&) reached
    What causes this issue? The system could not determine a table number.System Response The system issues an error message and will not allow you to c...

Click on this link to search all SAP messages.


Rating
The AI Support Assistant is great. It provides comprehensive assistance even on the most difficult issues. I highly recommend this service.
Rate 1
John Jordan
SAP Consultant & Author