Mentor SAP

Composition in Data Model Projection

Associations in CDS Projection Views

 

Just like the data definition of composite RAP Business object consists of several CDS view entities, its projection consists of several CDS projection views, one projection view for each of the data definition views. To build an OData UI service, each projection view is enriched with the UI metadata, preferably in a CDS metadata extension.

 

To make the structure of the business object available in the OData Service too, you have to establish the hierarchy on the projection layer. To do so, you need compositions and to-parent associations that link the projection views.

Redirecting Associations

 

Instead of defining completely new associations on projection level, we recommend reusing the associations from the underlying data model and redirecting them to a new target.

 

In the example, the data model view on the left (Z00_I_Source), defines and exposes an association _Asso that uses the data model view on the right as its target (Z00_I_Target).

 

The view on the upper left (Z00_C_Source) is a projection on of Z00_I_Source. It has access to the exposed association _Asso and can expose it further. But, by doing so, the association _Asso would still point to the data definition view Z00_I_Target.

 

The association is redirected by adding a colon, the keyword redirected to, and the name of the new target.

 

This syntax can be used for any kind of association, general associations, compositions, and to-parent associations. However, when using redirected to <target>, the special characteristics of the compositions and to-parent associations will be lost.

Redirecting Compositions and To-Parent Associations

 

For redirecting compositions and to-parent associations, ABAP CDS offers the dedicated syntax elements redirected to composition child and redirected to parent. By using these variants, the special characteristics of compositions and to-parent associations are kept.

 

When using redirected to composition child, the original association has to be a composition and the new target has to be a projection of the original target. When using redirected to parent, the original association has to be a to-parent association. The new target should be a projection of the original target.

 

Composition in Behavior Projection

Behavior Projection of Composite Business Object

 

To make the transactional enabling of the associations available in the OData service, we have to include it in the behavior projection. Similar to use create, use delete, or use action, a statement use association exists for this purpose.

 

If RAP draft handling is enabled in the behavior projection (use draft), the associations must be draft enabled using the syntax addition with draft;.

 

Facets and Additional Object Page in SAP Fiori

Service Definition for Composite Business Object

 

If a RAP BO projection consists of several entities, each entity has to be exposed in the service definition explicitly to make the hierarchy available in the service.

 

Visualization of Child Entity in Second Facet

 

In an SAP Fiori elements app, the composition can be displayed by adding additional facets to the object page. The facet can then contain a list of the related child entity instances. In the example, the object page for root entity Text contains a second facet, which displays a list of Text Lines.

 

UI Metadata for Second Facet