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

Inserting duplicate values when only MANDT is primary key

aris_hidalgo
Contributor
0 Likes
2,327

Hello experts,

I have 4 fields in my UDT(user defined table) namely MANDT, ZEVENT, ZRECIPIENT and ZEMAIL.

Now, Only MANDT is the primary key. My question is, how can I insert duplicate values

via SM30?

Again, thank you guys and take care!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,936

You cannot have only client field in the primary key if you want to maintain multiple records in your table.

In your table if you will always have one recipient per event then you should have ClientEvent as the primary key. If you might have more than one recipient per event then the primary key should be ClientEvent+Recipient.

Kiran

Please mark useful answers

Hello experts,

I have 4 fields in my UDT(user defined table) namely MANDT, ZEVENT, ZRECIPIENT and ZEMAIL.

Now, Only MANDT is the primary key. My question is, how can I insert duplicate values

via SM30?

Again, thank you guys and take care!

12 REPLIES 12
Read only

Former Member
0 Likes
1,937

You cannot have only client field in the primary key if you want to maintain multiple records in your table.

In your table if you will always have one recipient per event then you should have ClientEvent as the primary key. If you might have more than one recipient per event then the primary key should be ClientEvent+Recipient.

Kiran

Please mark useful answers

Read only

0 Likes
1,936

Hi again guys,

Thank you all for your helpful replies. However, I encountered another problem when I try to modify the values of the records via SM30. For example, record 1 has event 01, recipient 'AVH' and e-mail as [email protected]. Now lets say I want to change its recipient from 'AVH' to 'VIRAYLAB'. But when I click on save and then I check it again, it is still 'AVH'.

Read only

0 Likes
1,936

Hi viraylab,

1. we cannot change any field value

which is a part of the primary key

2. for that

3. we have to first delete that row,

4. and then add a new one.

regards,

amit m.

Read only

0 Likes
1,936

Hello guys,

Here is what I'm thinking, create another field in my UDT and name it as say, CDSEQ. This field will automatically create sequential numbers for every record added via SM30. So it will be my primary key and MANDT. My question is, after I have added the said field(CDSEQ), how do I make it invisible in maintenance view(SM30)? Also, What code can I make that for every new records, it will add 1 to its CDSEQ field?

again, thank you guys and take care!

Read only

0 Likes
1,936

Hi again,

1. What code can I make that for every new records, it will add 1 to its CDSEQ field?

For that we have to use

EVENTs for table maintenance.

We can use event 'Before Saving'

There we have to write some abap code,

which will fetch the last number,

add 1 and then update the field CDSEQ,

before saving.

regards,

amit m.

Read only

0 Likes
1,936

Hi Amit,

Thank you for your reply. So how can I make it invisible in SM30?

Read only

0 Likes
1,936

Hi again,

1. the full code for table maintenance,

is in a function group.

2. open that function group in new session

via se80 tcode.

3. in that identify the SCREEN

4. It will have table control

for the relevant fields.

5. choose your field,

and in property box,

make it INVISIBLE.

6. Activate the full function group again

7. In new session, try again with sm30.

regards,

amit m.

Read only

0 Likes
1,936

Hi again Amit,

I checked in SE80 and checked the screen for the said UDT table. Now, in the display attributes, the INVISIBLE checkbox is grayed for all the fields.

Read only

0 Likes
1,936

Hi again,

1. open the Layout of that screen

2. using drag&drop

just REMOVE the field from the table control.

3. Also

4. In the flow logic of that screen,

remove the line / commen it

which has been put in CHAIN

for eg.

  • FIELD YHRT_FUNMST-FUNSORT .

5. Activate everything

6. try again via sm30 in new session.

7. NOW IT WILL WORK. I JUST TRIED IT.

regards,

amit m.

Read only

Former Member
0 Likes
1,936

Hi Viraylab,

You cannot insert Duplicate records if there is an Primary Key. You can do if your Table has COmposite Keys.

Hope this would have helped you .

Cheers,

Prashanth

Read only

Former Member
0 Likes
1,936

Hi,

To insert duplicate values, make the following fields as key fields, MANDT, DATA & TIME in the table,

Hope this helps,

Rgds,

Read only

0 Likes
1,936

make another field also primary key.