Application Development 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: 

Reference key for 2 tables

Former Member
0 Kudos

Hi,

I have 2 questions

1) I have 3 tables, stay T1, T2 and T3. All three tables have field F1. F1 in T1 and T2 is a primary key. I want F1 in T3 to be foreign key to F1 in T1 and F1 in T2. i.e F1 entries in T3 should be either those of T1 or T2. Is this possible? If so how?

2) I also want the combined entries of T1 and T2 to be unique. How can I do this?

Thanks & Regards,

Reena

6 REPLIES 6

Former Member
0 Kudos

in T3 u can give as F1 as foreign key

in se11 , goto T3 , change , put the curson on F1 , then click the foreign key button , here u can declare it as foreign key of T1 , T2

0 Kudos

I am able to declare it either to T1 or to T2. How can I declare to both at the same time.

Former Member
0 Kudos

Hi reena,

1. F1 entries in T3 should be either those of T1 or T2. Is this possible

Its not directly possible.

2. One thing is :

<b>a) create a Z View which will have

entries from BOTH the tables T1, T2.

b) Give this VIEW as foreign-key table

in se11, for T3.</b>

3. I also want the combined entries of T1 and T2 to be unique. How can I do this?

For this we have to write some abap code,

while putting entries in to the table.

(the system cannot take care of both tables)

regards,

amit m.

0 Kudos

Hi Amit,

T1 and T2 are two independent tables. How can I create a view with F1 contains entries from both T1 and T2?

Thanks & Regards,

Reena

0 Kudos

Hi again,

1. Im sorry.

2. You are right.

3. (actually i thought it as a UNION-Query

for the view, which is presently not

possible in data dictionary)

4. We create a view directly

with entries from both t1 and t2 table,

but it won't probably work as a union query,

bcos we have to give join for both the tables.

regards,

amit m.

Former Member
0 Kudos

HI,

You can define a foreign key as dependent on any primary key. And about the records dependability, you can define the cardinality relationship in such a way that u achieve ur objective.

Reward if helfpul.

Regardds