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

Create unique constraint on table

Former Member
1,840

Hello experts,

Is it possible to define a unique constraint on table fields that aren't part of the primary key?

Thank you in advance.

5 REPLIES 5
Read only

Former Member
0 Likes
1,110

Yes.

Rob

Read only

0 Likes
1,110

Thank you Rob, how can i achieve this?

I'm trying to create an aditional constraint that doesn't allow the insertion of a record that fails this constraint.

Read only

0 Likes
1,110

Create a unique index on the table.

Rob

Read only

Former Member
1,110

One way is to create an index on the field and make it unique (SE11->GOTO->Indexes). Then in your programs Inserts, Appends and Updates would fail giving you a non zero SY-SUBRC when a program tries to enter a value that already exists.

Don't forget to include MANDT in the index otherwise you'll end up with uniqueness across all clients

Read only

0 Likes
1,110

Problem solved! Thank you