Skip to Content
author's profile photo Former Member
Former Member

Problem with Foreign Key relationships in SAP R/3 4.7

Hi Experts,

I am trying to create a foreign key relationship between 2 transparent tables in SAP R/3 4.7

Table 1:ZAAVNDR (MANDT (pk), VENDORNO (pk), NAME, REGION, COUNTRY (fk)) Foreign Key Table

Table 2: ZAAVNDRREF(MANDT(pk), COUNTRY (pk)) ---Check table

I have added few valid countries in check table but when I am adding some records in foreign key table with invalid countries these records are not being restricted and are still successfully going into the table.

Could any one please help in this.

Thanks in anticipation.

-Amit

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 03:56 AM

    In both the table COUNTRY field should be Primary Key.

    In your case , in table ZAAVNDR , it is not.

    Make COUNTRY as primary key in ZAAVNDR table.

    It will work as your requirment.

    Regards,

    Anirban

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 14, 2009 at 05:51 PM

    While defining the foreign key relationship please check to see if the 'Check Required' flag in the 'Screen Check' section has been selected.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2009 at 09:31 PM

    How are you adding entries to the table? If you are doing it through a program via an INSERT statement, then the check is not performed. You will have to do that in your program.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I am adding records by using the Menu (Utilities->Table Contents->Create Entries). Even after making Country PK in both the tables still the records are not being restricted.

      Could you please help.

      Thanks

      -Amit

  • Posted on Aug 14, 2009 at 07:32 AM

    Hi,

    Please go through following points, I hope it will helpful for you.

    1. Maintain primary key in field 'COUNTRY' in both the tables (foreign key table & check table). Note: both fileds should have same data element.

    2. Maintain foreign key relation for field 'COUNTRY' in foreign key table.

    3. Since table is changed so you need to "Activate and Adjust Table" using transaction SE14

    Regards,

    Moqeeth

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 14, 2009 at 07:54 AM

    From the previous replies I think that maintaining the foreign key relationship for country code via SE11 in the vendor table is essential, however the primary key should remain unchanged. I mean, how can you recommend changing the primary key to country code in a table with data related to vendors?

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 04:44 AM

    Check

    1. The domain of the COUNTRY field in both the table are same.

    2. The Foreignkey relationship is created properly .

    3. all the table and components are active.

    Anirban

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 15, 2009 at 10:40 PM

    Did it by mistake. Still the problem is not resolved.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.