cancel
Showing results for 
Search instead for 
Did you mean: 

Can we delete primary key in sap s4hana cloud?

Ruchi691
Participant
0 Kudos

Hi SAP,

I m trying to delete the a primary key in my custom cds view, but somehow its showing as grayed out ( non delete ) field.

Is there any way I could delete the primary key.

Could you please confirm or provide me documents to refer?

Thanks and Regards

Ruchi Kesharwani

Marissa
Advisor
Advisor
0 Kudos

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if you have further questions.

Accepted Solutions (1)

Accepted Solutions (1)

AndreasRiehl
Advisor
Advisor
0 Kudos

Hello Ruchi,

As Amit said, elements of a custom CDS views can only be removed if they are not used. Nevertheless, the key fields are an exception. They can usually not be removed at all due to stability reasons. What you can do is to hide them in the consumption (this is an option in the element properties). Hiding a field will make it invisible in the final consumption runtime (e.g. in an an analytical query or in an odata service). Setting the hidden property will write the @Consumption.hidden annotation to the element. Also see https://help.sap.com/doc/saphelp_nw75/7.5.5/en-US/d6/0c0bf6798a481fb7412bc89934cb8a/content.htm

Best Regards,
Andreas

Answers (1)

Answers (1)

Amith_Nair
Advisor
Advisor
0 Kudos

Hi Ruchi

Please confirm if you have any dependency linked to your custom CDS view like a Custom Analytical Query. If yes, then you need to uncheck that specific field from your query first and then save and publish the query. Return back to the field in CDS view and see if it’s available for deletion. Please check and confirm.

Ruchi691
Participant

Hi Amith,

It has no dependency. Still its not letting it delete. Is it because its a primary key ?

Thanks and Regards

Ruchi Kesharwani

Amith_Nair
Advisor
Advisor
0 Kudos

2022-09-19-08-18-15.jpgHi Ruchi,

As you pointed out, since it's a Primary key, it does not let you delete, but you have an option to hide in the Element Properties section as depicted in my screenshot.

Hope this does the trick in your scenario. Please close the thread, if this helps!

Thanks! Amith Nair

Ruchi691
Participant
0 Kudos

Hi Amith,

I tried enabling the hide for both key and non key fields in element properties as shown below:

but its not reflecting in preview. Could you please suggest why the field is not getting hide.

Thanks for your response,

Ruchi