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

Primary/Composite keys combination doesn't work.

former_member295881
Contributor
0 Likes
2,237

Hello Experts,

I've build a custom table with three primary/composite keys, including Customer (KUNNR), Billing Type (FKART) and Output Media (ZZ_MEDIA) (as shown below).

However, the issue is I can insert records without Billing Type and Output Media via SM30 as shown below.

Question is, is there anything I can do to prevent it?

Many thanks in Advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,785

Hello,

Composite key is a combination of two or more primary keys in a table.

When you maintain the table, it will take a unique combination of all mentioned keys. even if you enter the value of one primary key and left the remaining primary keys blank, it is a possible combination, so the entry will be added to the table.

If you have requirement to add entry to table only when all the primary keys are entered, you can do the following:

1. Go to table maintenance generator. (Create one if you don't created it already)

2. Go to Menu Environment -> Modification -> Maintenance Screens

It will take you to the screen painter. Now go to Layout. There u can see the screen, the same screen u can see when u execute transaction SM30.

3. Go to the desired tab and make the field as mandatory.

Once you click on respective field tab, You can see the Screen painter: attributes screen , in that go to Attributes tab, Select Program Tab and make input as required from the drop-down.

so the respected Key field become mandatory. You can do the same procedure for other key fields. So entry will be added to table when you provide all primary key values.

Thanks,

Mayuresh

Hello Experts,

I've build a custom table with three primary/composite keys, including Customer (KUNNR), Billing Type (FKART) and Output Media (ZZ_MEDIA) (as shown below).

However, the issue is I can insert records without Billing Type and Output Media via SM30 as shown below.

Question is, is there anything I can do to prevent it?

Many thanks in Advance.

3 REPLIES 3
Read only

Former Member
0 Likes
1,785

Try creating Table Maintenance Generator and from table maintenece generator screen goto

Environment -> Modification -> Maintenece Screen and make that field mandatory.

Read only

Former Member
0 Likes
1,786

Hello,

Composite key is a combination of two or more primary keys in a table.

When you maintain the table, it will take a unique combination of all mentioned keys. even if you enter the value of one primary key and left the remaining primary keys blank, it is a possible combination, so the entry will be added to the table.

If you have requirement to add entry to table only when all the primary keys are entered, you can do the following:

1. Go to table maintenance generator. (Create one if you don't created it already)

2. Go to Menu Environment -> Modification -> Maintenance Screens

It will take you to the screen painter. Now go to Layout. There u can see the screen, the same screen u can see when u execute transaction SM30.

3. Go to the desired tab and make the field as mandatory.

Once you click on respective field tab, You can see the Screen painter: attributes screen , in that go to Attributes tab, Select Program Tab and make input as required from the drop-down.

so the respected Key field become mandatory. You can do the same procedure for other key fields. So entry will be added to table when you provide all primary key values.

Thanks,

Mayuresh

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,785

Did you create some foreign key relations to check value of FKART (TVFK) and ZZ_MEDIA (z-table) as I suppose you did for KUNNR with KNA1-KUNNR (check required, key fields/candidates, cardinality 1:CN)

Sample KUNNR in KNB1, check table KNA1:

Regards,

Raymond