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: 

problem with foreign key relation

Former Member
0 Kudos

i created two ztables ...

maintaned foreign key relation for one field.but if i insert some entries other than the entries in check table it is taking those entries. there is no error message....pls explain.

1 ACCEPTED SOLUTION
7 REPLIES 7

Former Member
0 Kudos

Hi,

1. Foreign key relation ships,

in SAP abap,

allow to BYPASS IT.

2. They are just meant

for showing master list

in ABAP Module pool.

3. It won't DO ANY CHECK

while directly entering in table.

Regards,

Omkar.

Former Member
0 Kudos

Hi,

I just created 2 tables for your reqt and tested .its working fine.

I have created ZEMP table with fields

empno --> char 4 --> Pkey

ename --> char20 --> not pkey

deptno --> char2 --> not pkey

i created 1 more table ZDEPT table with fields

deptno --> char2 --> pkey

dname --> char15 --> not pkey

Maintain technical settings for 2 tables like

Data class: Appl0,

size category: 0

and activate both the tables.

In each table atleast 1 field should be pkey.otherwise u will get error that you can see in activation log when you do activation.

Maintaining foreign key relation ship:

goto ZEMP table and place cursor on deptno and press Foreign key button (after newrows 1 button is there na that button ).

then enter ZDEPT in the place of check table text box ,short text and press "Generate proposal" button.

you will get proposal and just press " Copy " button or enter button.no need to enter other values in this screen if not required specifically.

Testing:::::::::::

Now maintain table maitenance generator using

Utilities->TMG->enter auth grp as &NC&.

and go back and again goto

utilities-->Table contents->create entries.

now you give some values.

you will get error there itself.because you didnt maintain entries in ZDEPT table as it is check table ZEMp table.

Regds

Sivaparvathi

Please dont forget to reward points if helpfull

0 Kudos

hai ..i did the same thing... i insert some entries for deptno in dep table first.and i insert someother entries which r not in dept table it accepts for deptno in emp table..

and i am using 4.7 version..

0 Kudos

Hi,

you want to check the field deptno in dep Table while entering values in Field deptno of other Table.

so that it won't alow the duplicate values. Right?

But validations are not possible at table level. that's why when ur entering the deptno diffrent from actual no also, it is storing in the database.(it will not check the value in the dept table).

validations can be defined at the application. we can

validate the screen field(Ex:deptno) before entering value into the database table.

we have to write a small code for that.

If u want to do ..

1. U must have defined DOMAIN

thru se11.

2. In that there is one TAB (Value Range)

3. At the bottom most,

There is a VALUE TABLE.

4. In that Enter the MASTER Table.

Regards,

Omkar.

Former Member
0 Kudos

Hi

Instead of just giving the check table fields, just generate a proposal and then activate the table. I guess this will work for u. Also check if u have given the messsage class number correctly.

with regards,

hema.

prasanth_kasturi
Active Contributor
0 Kudos

create a table maintenance generator path is utilities--> table maintenance generator. and then maintain the values using sm30. u will have a reference check

awrd if helpful

Edited by: prasanth kasturi on Jan 7, 2008 10:27 AM