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 relation

Former Member
0 Likes
1,022

Hi All,

Could anyone help me out in this issue.i'm facing problem while giving a check table relationship in 4.7 version.

I had two tables ZTERM_k and ZTERM_P

ZTERM_K has fields MANDT and TERMDESC(terminal name) both the fields are marked as primary keys.

ZTERM_P has fields MANDT , TERMDESC and PRDHA. here only MANDT is marked as primay.

Table one has a unique key. This table will be used in the select option of the report to present the available options (similar to value keys).

i.e. 040 ALTURA

040 ITVM

040 SST

040 All SSP

Table two has a non unique key. In this table there will be a row for each product and the associated relationship. This table will be used to build the select option range that the program logic relies upon to read the database. In some cases the relationship of product is 1 for 1. In other cases, the table will contain 1 to many relationships (i.e ALTURA associated with product hierarchy codes ALT, ALT2, ALT4).

i.e. 040 ALTURA ALT

040 ALTURA ALT2

040 ALTURA ALT4

040 ITMV EDS

040 ITVM EDSQ

040 ITVM GG

040 SST SST

This is how we have the input in both the tables. i created the firs table ZTERM_K and added entries to it.the same way i created the table ZTERM_P

and selected the field TERMDESC and clicked on foreignkey tab gave the table name ZTERM_K and activated.

TERMDESC gives the values of ZTERM_K only.

TERMDESC key has several combinations of PRDHA in 2nd table.

now when i create the entries i'm able to enter only one entry.and not able to enter any entrys's with any combinations. it is displaying a message "A data record with specified key already exits".

waiting for your response.

Thanks & Regards,

Rayudu

Hi All,

Could anyone help me out in this issue.i'm facing problem while giving a check table relationship in 4.7 version.

I had two tables ZTERM_k and ZTERM_P

ZTERM_K has fields MANDT and TERMDESC(terminal name) both the fields are marked as primary keys.

ZTERM_P has fields MANDT , TERMDESC and PRDHA. here only MANDT is marked as primay.

Table one has a unique key. This table will be used in the select option of the report to present the available options (similar to value keys).

i.e. 040 ALTURA

040 ITVM

040 SST

040 All SSP

Table two has a non unique key. In this table there will be a row for each product and the associated relationship. This table will be used to build the select option range that the program logic relies upon to read the database. In some cases the relationship of product is 1 for 1. In other cases, the table will contain 1 to many relationships (i.e ALTURA associated with product hierarchy codes ALT, ALT2, ALT4).

i.e. 040 ALTURA ALT

040 ALTURA ALT2

040 ALTURA ALT4

040 ITMV EDS

040 ITVM EDSQ

040 ITVM GG

040 SST SST

This is how we have the input in both the tables. i created the firs table ZTERM_K and added entries to it.the same way i created the table ZTERM_P

and selected the field TERMDESC and clicked on foreignkey tab gave the table name ZTERM_K and activated.

TERMDESC gives the values of ZTERM_K only.

TERMDESC key has several combinations of PRDHA in 2nd table.

now when i create the entries i'm able to enter only one entry.and not able to enter any entrys's with any combinations. it is displaying a message "A data record with specified key already exits".

waiting for your response.

Thanks & Regards,

Rayudu

6 REPLIES 6
Read only

Former Member
0 Likes
955

Hi,

While giviign check table relation ship . u check it properly.

I am suggesting:

activate zterm_k.

go to zterm_p

select terdesc field ...

goto forein field

then select field relationship...

And set CARDINALITY, i think here u r missing something .. u give proper cardinality and hope it will work. (combination of C, N, 1)

Read only

0 Likes
955

Hi jogdand,

Thanks for your reply,I checked but it did not work.

Rayudu.

Read only

Former Member
0 Likes
955

Do the following :

Create the foreign Key as :

ZTERM_K - check table

TERMDESC - check table fld

ZTERM_P - Foreign table

TERMDESC - Foreign key field

Semantic attributes :

Foreign Key field type : Key fields / candidates

Cardinality 1 : CN

This should ensure that insertion of new records is allowed

Read only

Former Member
0 Likes
955

do this way...

Create foreign Key

ZTERM_K - check table

TERMDESC - check table field

ZTERM_P - Foreign table

TERMDESC - Foreign key field

Semantic attributes :

Foreign Key field type : Key fields / candidates

Cardinality 1 : CN

Read only

Former Member
0 Likes
955

While giving the foriegn i think u have check the checkbox named check table.This will only make a check while u entering a value in secondary table where the primary key field of primary table is used..

Otherwise give a primary key field newly other than MANDT.

Reward if useful

Read only

Former Member
0 Likes
955

Hi All,

Thanks for your Support and suggestions, I solved the problem on my own.

The problem is in table ZTERM_P termdesc and Prdha fields should be marked as

primary. it is a combination of keys.

Appreciate your help and request you to continue.

Thanks & Regards,

Rayudu