cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to define multiple to parent associations in RAP?

JosefG
Explorer
0 Likes
1,063

Hi all,

I am trying to build multiple RAP-based Fiori apps which all have two levels of information.

The first level (BO context) always contains business header data for business objects like Sales Order or Purchase Order.

The second level contains additional information from an external system about the specific business object id. This information needs to be fetched by an API call for each specific Business Object Id and there can be 0 to many results. The information cannot be fetched by querying CDS views or tables.
To achieve that a custom entity is used which then calls the API in the query provider class. 
Since the custom entity could be defined and implemented generically for all BO contexts the idea is to reuse one custom entity for all business object-specific apps.

In the custom entity the association(s) to the parent BO context(s) are specified. 
In the root view entities for the BO contexts the relation to the additional information is specified as composition. 

That means the BO context is the root object and the additional information is the child. 

Unfortunately it is not possible to define multiple to-parent associations in the child entity (additional information). But that is needed to build up the RAP app where for instance the authorization and the locking of the child should depend on the parent.

As an example the hierarchy would look like:

BO Context Sales Order
--> Custom Entity Additional Information

BO Context Purchase Order
--> Custom Entity Additional Information

Is there a solution to achieve that?

If there is no solution there would be a need to duplicate the definition for the custom entity for each BO context and that should be prevented.

Thanks and best regards!

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion
0 Likes

do you really have to go with composition?

why not association?

JosefG
Explorer
0 Likes

I already changed to an association but now in the behavior definition I get following error for the definition of the child entity:

<custom entity> is not a subentity of the root entity <business context>.

junwu
SAP Champion
SAP Champion
0 Likes
dude, don't just put the error msg, show you what you did....
JosefG
Explorer
0 Likes

Doing a more loose coupling by using association instead of composition was the solution.

The custom entity was then also declared as root entity and as a result also an own behavior definition was created for the custom entity.

With that in place the custom entity can now be used by multiple business-context specific entities which corresponds in the end to separate Fiori apps. 

Answers (0)