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

Compound primary key

Former Member
0 Likes
465

Hello,

I want to make an internal table, that should behandled by a compound primary key. I'm German and I am not sure what's the english word for zusammengesetzter primärschlüssel. I mean I have e.g. 4 Primary Keys. An valid Dataset must have a unique COMBINATION of these 4 Primary keys.SO that's what I am looking for. I tried doing it with a SORTED TABLE:

tabLine TYPE SORTED TABLE OF Line WITH UNIQUE KEY Key1 , Key 2.

But this is not what I want. Now ABAP wants to be each Primary Key to be unique. But I want to have a unique COMBINATION of all Primary Keys to be unique. My next idea is to make "a table in a line" and this will be my primary key. But I am not sure if that would even work and if there isn't a much easier way in ABAP. So I am asking you again

thank you.

1 ACCEPTED SOLUTION
Read only

Sm1tje
Active Contributor
0 Likes
434

tabLine TYPE SORTED TABLE OF Line WITH UNIQUE KEY Key1 , Key 2.

This uses the combination of the four key fields as unique. So every row in this internal table is unique for the keyfields key1, key2, key3 etc.

2 REPLIES 2
Read only

Sm1tje
Active Contributor
0 Likes
435

tabLine TYPE SORTED TABLE OF Line WITH UNIQUE KEY Key1 , Key 2.

This uses the combination of the four key fields as unique. So every row in this internal table is unique for the keyfields key1, key2, key3 etc.

Read only

Former Member
0 Likes
434

Seems to work now. I tried the same thing a few hours ago and it didn't work. Looks like there was some kind of typing error