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: 

Foreign Key Problem.. plz help urgently

Former Member
0 Kudos

I have a Z table having these fields....

MANDT MANDT

GSBER GSBER (primary key also)

HBKID HBKID

Foreign key is defined for GSBER (taken from TGSB table)

Check table is defined both for GSBER and HBKID..

i have created a table maintainence generator also..

my Requirement is that... When i am entering value in the table...

for One value of GSBER there can be only one value of HBKID

basically a 1 is to 1 relationship...

i wil give an example..

GSBER HBKID

120 555 ( Right)

120 545 (not Allowed)

343 555 (not allowed)

ps: I have tried making the HBKID also as primary key... but then it is accepting values which are null. so i dont think thts right...

How can i use cardinality in this case.... If that is the solution?

thanks

Ankit

2 REPLIES 2

Former Member
0 Kudos

Hi Ankit,

1> Make the field GSBER as mandatory in overview and single screen in table maintainance->double click the screen numbers->element list->special attr.->make input as required so that <b>null value</b> won't be accepted.

2> Create a event in table maintainance ( <b>creating a new entries</b> )

3> write an select query to check whether this value already exist in table in the fields GSBER, HBKID.

SELECT GSBER HBKID INTO WS_ZTABLE

FROM ZTABLE

WHERE GSBER EQ ZTABLE-GSBER OR

HBKID EQ ZTABLE-HBKID.

4> IF any values found then display 'error message'

else accept the entries.

I think this will solve ur problem

Regards,

Nithya

Former Member
0 Kudos

create table with 3 fields as you are .

<b>MANDT MANDT

GSBER GSBER (primary key )

HBKID HBKID</b>

Only Gsber is primray key ...

no check table for both fields ...

now try it

it will give as

<b>

GSBER HBKID

120 555 ( Right)

120 545 (not Allowed)

343 555 (Right)

343 545 (not Allowed)</b>

reward points if it is usefull ....

Girish