Annotation @AnalyticsDetails.query.displayHierarchy: #ON is used for displaying the hierarchy for employee.

Annotation @AnalyticsDetails.query.hierarchyInitialLevel: 10 is used for default expand level.

Testing the Analytical query:

Tcode RSRT is used for testing analytical query, give in the Query field 2CZEMH_IEQ3 (2C must be added to every analytical query while testing) and execute as show below:

Result of the Query is shown below:

Annotation @AnalyticsDetails.query.axis: #ROWS is used for defaulting attribute to row characteristics in query browser. if you give axis to COLUMN the it defaults attribute to column in query browser.

Annotation @AnalyticsDetails.query.display: #KEY_TEXT is used for displaying text of the key. i.e EmployeeName for Employee.

Annotation @AnalyticsDetails.query.totals is used for displaying totals. Here totals are hidden.

Annotation @AnalyticsDetails.query.hierarchySettings.hidePostedNodesValues: true will hide the node values. if you give this as false or remove this annotation then result will have node values as shown below:

Annotation @AnalyticsDetails.query.formula is used for calculating utilization rate of employee based on planned and actual working hours. So, in this annotation you can write any mathematical formula which is executed dynamically in analytical engine.

Note: The results of analytical query, cube, fact and dimension are recommended to execute from RSRT* transactions as shown, you wont get expected results if you go with normal F8 execution of CDS because execution happens at analytical engine

From above steps hierarchy is achieved.

Annotation @OData.publish: true is used for publishing the service. See my previous blog expose cds view as OData service which shows how to activate the service.

Once service is activated then you can open the service as below :

Click on Odata service link to open the service:ZEMH_C_EMPLOYEEQUERY3_CDS with entity set: ZEMH_C_EMPLOYEEQUERY3 as shown below with properties:

Now backend task of evaluating Employee Manager hierarchy using analytical query CDS view and publishing the Odata service is done. Now we go to next step i.e creating the hierarchy application UI in the WebIDE.

5. SAPUI5 application for Hierarchy:

Open WebIDE and create a new project form template:

Choose SAPUI5 application from the template

Enter Project Name:

Select View Type as XML view and give view name as HierarchyView and finish the project wizard:

Now local Annotations needs to be created for OData service before that create a folder annotations :

In this new folder “annotations”, create a file “annotations.xml”:

copy the local annotations into annotations.xml file which describes the UI properties that cannot be derived from CDS annotations

local annotaion above defines which UI properties such as UI.LineItem, Common.ValueList(filter or valuehelp) visible default in the UI. Here in our example attributes Employee_NodeText, UtilizationRate_F, CostCenter are lineitems and CostCenter is defined as Valuehelp or filter

Now register the service as a datasource to the application for this open manifest.json with the Descriptor Editor, switch to the “Data Sources” tab, and enter the service under name “ZEMH_C_EMPLOYEEQUERY3_CDS“. Afterwards, add an entry to the “Annotations” section, with name “localAnnotations“, URI “annotations/annotations.xml” pointing to the file just created, and the same URI for the local URI. With this, the form should look like below:

Click on + button as shown above to add the service

Now define a model with which the UI view can access the data source. For this, save changes and switch to the Code Editor for manifest.json, locate the section “sap.ui5.models”, and add this new model with an empty identifier (“”). Save the changes:

if annotations are appearing red that means it is version problem, some times even after appearing red they might work and they automatically change to original color once version updated.

Text of Employee not showing up in RSRT because in Dimension view of Step 1 I have used @ObjectModel.text.element: [ ‘EmployeeName’ ] for Employee key field and explanation for this annotation is provided there. Please check in your code whether this was handled, if it is handled still it is not showing up it might be version issue since it is appearing red.