Skip to Content
1
Jul 12, 2022 at 12:03 PM

Associations in custom entities in SAP RAP

1481 Views

Hi,

I have a simple RAP based OData Service with two custom entities which are associated one to another like so:

Root entity "RUN"

bildschirmfoto-2022-07-12-um-133804.png

Root entity "MESSAGE"

bildschirmfoto-2022-07-12-um-133328.png

So when I call all or a single "run" entity/ies, everything works fine.

Now I want to call the navigation property "to_Messages" of a single "run" entity, to display the results in a lineitem annotation like so:

/sap/opu/odata/sap/ZBI_MXF_RUN/ZDD_I_MXF_RUN(vtype='AB02FG',run_id='206')/to_Messages

I thought that as soon as I call the association, the RAP framework would call the if_rap_query_provider~select method of the class, which I defined in the child(associated) entity, like ZCL_CE_MXF_MESSAGE but instead, the framework calls the select method of the "run" entity in the ZCL_CE_MXF_RUN class.

If this works as intended how can I distinguish, which association was called? In the debugger it seems that it is a normal getEntity call of the "Run" entity with no additional information about the association or anything else, that could help me.

bildschirmfoto-2022-07-12-um-135711.png

When I call the "Message" entity itself, the corresponding select method in the "Message" class is called. But not when I call it as an association of the "Run" Entity. I configured the relation between the two entities as composition in the first place, like in the answer of Andre Fischer in the question https://answers.sap.com/questions/13631104/abap-rap-complex-logic-for-read.html, but it was no difference.

Did I configured something wrong?

Best Regards

Dominik