cancel
Showing results for 
Search instead for 
Did you mean: 

Error: "There is already an entry with the same key information"

former_member276384
Participant
0 Kudos

Hello SAP MDG experts,

we're facing an issue in our MDG-S project on our custom entities when they are lists. If more than one entry is added to the list, an "There is already an entry with the same key information" error is raised.

We don't know how to deal with it. We are using as reference the model entities BP_ROLE & BP_ROL_ID.


The custom entity is type 4 (Changeable via Other Entity Type; Generated Database Tables)  and the relationship with BP_HEADER entity is "Leading" type and 1:N cardinality, and a Qualiying relationship with an ID entity (ZCOMPR_ID):

BP_ROLE

Custom Entity

Thanks in advance and best regards,

Jordi

Accepted Solutions (0)

Answers (2)

Answers (2)

h_h_ak
Participant
0 Kudos

Hey Jordi,

last week I got the same error message when I am working with Feeder classes. To solve this problem I deleted my first redefined class and added a new one with the same content.

The error message doesn't apperead.

If you work with the UI you should to verify it.

former_member276384
Participant
0 Kudos

Hi Hasan,

I'm not sure if I have understanded you correctly. Please, could you be a bit more explicit?

Best regards,

Jordi

h_h_ak
Participant
0 Kudos

Hey Jordi,

sry for my bad expression.

I got the same Message, when I redefined the feeder class CL_BS_BP_GUIBB_ADDRESS_STD.

Everytime, once I clicked of the check button or do a refresh the message was displayed. I'm sure, if you change the feeder class with the origin one you won't get the error message.

I solved the problem while I created a new z-feeder class and assigned it again. The new feeder class was the same like the first one.

The only difference was, that the message not appeared.

former_member276384
Participant
0 Kudos

OK Hasan,

I think that I understanded it. What a strange behaviour!

But I think that my case is a bit different, because my entity is a customer entity and the feeder class is a brand new Z custom class which inherits from CL_BS_BP_GUIBB_LIST standard class and redefines the IF_FPM_GUIBB_LIST~GET_DATA method.

Best regards,

Jordi.

bavinash1
Explorer
0 Kudos

Hello,

I think I can add a little here.

Key handling is generally done at the feeder class level.

There are multiple types of keys we generally deal with like semantic keys and technical keys.

Both of them have to generated newly whenever we are adding a new entry to the entity and this has to be done in the feeder class.

In case you want a new technical key, you can use the convinience API and it'll generate a key for you.

In case it is a semantic key like bank, we might want to handle it in the get_data of feeder class ourselves.

Please see what is the data that you are getting to the process event of the corresponding feeder class as soon as you add some data hit enter.

Then manipulate the key for the newly added key which is generated wrt to the current entity. You could use a simple counter.

This should definitely solve the issue.

This ideally should have been taken care of in the standard itself, but a simple redefinition like above would definitely solve the issue

Regards,

Avinash

Former Member
0 Kudos

Hi Avinash,

I have the same problem which describes Jordi, I tried to add a counter in the temporal key in get_data method, but the result is the same, the error message still appearing.

In addition, the Z entity wich fails, have this aspect in MODEL:

The utilization class, does not allow to mark fields as key, it could be the reason of the problem? if so, how it could be solve? Thanks.

Regards,

RoyoX

bavinash1
Explorer
0 Kudos

Hello RoyaX,

As long as there is a qualifying and a leading relationship maintained for the type 4, we are fine.

A qualifying relationship creates a key to the to entity.

You could run the report USMD_DATA_MODEL and check the keys in the generated check table of the entity if you want to double check the keys.

Coming the issue: if that is the case, the ideal place to check would be write_entity_data of convinience API, cl_usmd_conv_som_gov_api . Whatever data is written to the CR will be routed only from this. Here, we could probably get an understanding of the keys of the entity data for the entity in question and understand whether it is being overwritten from what we have supplied.

Hope this helps.

BR,

Avinash

Former Member
0 Kudos

You need to have a key field on the custom entity. The group field will probably be a good choice.

former_member276384
Participant
0 Kudos

Hi Abdullah,

thanks for your answer, but I'm afraid that I could not find where to set the key field. I followed the BP_ROLE entity & relationships and also the BP_TAXNUM entity & relationships as our model but I have not seen any key field.

Best regards,

Jordi.

Former Member
0 Kudos

you need to have two relationships: a leading relationship to the business partner and a qualifying relationship to the group. this will make those two fields your uniquely identifying key.

former_member276384
Participant
0 Kudos

Hi Abdullah,

Thats is the way how I have the model, but the the error message is raised always when inserting more than one record on the table.

Best regards,

Jordi

Former Member
0 Kudos

I can't see a leading entity in your relationship. Any way, is your FPM defaulting an empty line? It could be that the moment you add a new line before selecting a group, it is finding that it is a duplicate.

former_member276384
Participant
0 Kudos

Hi Abdullah,

FPM is not defaulting an empty line.

In my model the relationship HAS_COMP is the leading relationship and the relationship QLF_COMP is the qualifying relationship. This creates a BP_HEADER + ZCOMPR_ID key, isn't it?

We have redefined the IF_FPM_GUIBB_LIST~GET_DATA method and after calling the superclass method we add our custom code. After that, the CT_DATA global variable is filled correctly, and without a duplicate key (BP_HEADER + ZCOMPR_ID).