cancel
Showing results for 
Search instead for 
Did you mean: 

CDS custom entity as association in RAP

former_member14709
Contributor
0 Kudos

Hello Experts,

I am working on S4 HANA 1909 on premise system. I am developing an app based on RAP architecture. The app consists of a root entity and its child and grand child entities. For one of my requirement, I had to create a CDS custom entity to write ABAP logic to populate entity. I tested this Custom entity by creating a test Service definition and binding and this works as expected. Now I have to associate this Custom entity to my root view so that I can see its data in a tabular format in RAP preview when I click on any entry of my parent entity in preview tool.

To achieve this, I linked this custom entity via association to my root entity and exposed this association in interface and consumption views. I also added another facet for this association in my metadata extension so that it displays in tabular format when I click on root entity entry. However, this does not work. When I run the preview and click on any root entity entry, I can't find the new facet which I added (probably because the target element in facet is a custom entity).

I tried replacing my custom entity name in target element with another association which is not a CDS custom entity, then it works totally fine. Could you please confirm if this is a limitation of CDS custom entity or am I missing something somewhere?

In RAP open SAP course, CDS custom entity has already been used as an association and later consumed as value help, but I couldn't find an example anywhere which fits to my requirement.

Thanks,

Aman Garg

md_zohaib_akhter
Explorer
0 Kudos

Hi Aman,

Did you find a solution to associate custom view entity to root entity? I have a similar requirement as well.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Hi Aman,

If the requirement is of having an editable table in a new facet linked to your parent entity, then you will need to link your parent entity with child entity using composition in behavior definition. Using composition you will be able to lock child date linked to parent data (root) as soon as user clicks on edit on root edit button.

If the requirement is of having a read-only table in a new facet linked to your parent entity, then you will use association to link your parent entity with child entity. To achieve this, create interface and consumption view for child entity. Use association in consumption view of parent entity and link consumption view of child entity with keys. Try executing the parent entity CDS and you should be able to see child entity data in ADT. In MDE or consumption view of parent entity, declare the new facet using UI.facet annotation. In service definition expose child entity consumption view. Unpublish service bindings and publish it again. Launch the preview of parent entity and you will be able to see the new facet with the read only table.

Regards,
Rohan Bhateja

ok678
Explorer
0 Kudos

late but your answer was so helpful. Thanks