Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Foreign Key Issue

Former Member
0 Likes
1,191

Hi all,

I am facing one issue..

There are two tables, one is the header amd the other is transaction table..

I have assigned a primary key to one field in the header table and assigned the same field as foreign key in the transaction table.

The issue is in the transaction table. I have 3 records with same number. But the system allows only one record to get inserted.

Foreign key concept is not applicable to this.

Any solution?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,107

Hi Yash,

I don't think this has to do with the foreign key settings.

You probably have only that number as the primary field in your item table.

Mark the item number or line number or whatever the field is to distinguish between the records with same number also as a primary field. Then you will be able to insert more records for the same number.

6 REPLIES 6
Read only

KiranJ
Active Participant
0 Likes
1,107

Hi, It should be combination with item number then only it will allow you create the multiple records in the item table , means your item table should of two primary key one is main field + item as primary key, For Refernce check in VBAK and VBAP table.

Read only

0 Likes
1,107

Select the cardinality attributes as 1:N

Read only

Former Member
0 Likes
1,108

Hi Yash,

I don't think this has to do with the foreign key settings.

You probably have only that number as the primary field in your item table.

Mark the item number or line number or whatever the field is to distinguish between the records with same number also as a primary field. Then you will be able to insert more records for the same number.

Read only

former_member129652
Active Participant
0 Likes
1,107

Hi,

  Please tell us what the primary key is in the transaction table.  Are the primary key and foreign key the same in the transaction table?  If yes, you should add one new field (for example, a sequence number field ) to the primary key in the transaction table. 

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,107

If you require zero to many items for a single header (not very original, isn't it) you must add a significantfield or a counter-type number in the item table. Look at any similar transaction tables like EKKO/EKPO, MKPF/MSEG or many other header/detail couples.

Remember the primary key implies uniqueness (and not-null too)

Regards,

Raymond

Read only

Former Member
0 Likes
1,107

primary key will not accept duplicate entry..

to solve this problem you have to add one more primary key..

assume you have two primary keys RECORD and SERIAL_NO, & you have records with same number number, then you can enter it like..

RECORD    SERIAL_NO

record1           1

record1           2

record1           3