For space requirements this blog has been split in 4 parts:

   Link   Content
Hierarchy evaluation using CDS Table Function  Hierarchy evaluation using CDS Table Function in S/4
Step 1 – Hierarchies in S/4 HANA  Analytics  Step 1 – Hierarchies in S/4 HANA  Analytics
This part  Step 2 – Define the Analytical Query CDS View
 Step 3. Smart TreeTable UI for Hierarchies  Step 3 – Smart Tree Table UI for Hierarchies

In continuation to previous blog Step by Step Hierarchies in S/4 HANA Analytics here I will show creation of analytical consumption query View which is used for generation of hierarchy.

4. Analytical Query Creation: View becomes query view if annotation @Analytics.query: true is used, this annotation makes this view visible in query browser.

@EndUserText.label: 'Display a Branch of the Employee Hierarchy with Utilization Rate' @AbapCatalog.sqlViewName: 'ZEMH_IEQ3' @Analytics.query: true @OData.publish: true define view ZEMH_C_EmployeeQuery3 as select from ZEMH_I_EmployeeHours1 { @AnalyticsDetails.query.displayHierarchy: #ON @AnalyticsDetails.query.hierarchySettings.hidePostedNodesValues: true @AnalyticsDetails.query.hierarchyInitialLevel: 10 @AnalyticsDetails.query.axis: #ROWS @AnalyticsDetails.query.totals: #HIDE @AnalyticsDetails.query.display: #KEY_TEXT Employee, CostCenter, PlannedHours, ActualHours, @AnalyticsDetails.query.formula: 'ActualHours / PlannedHours * 100' @EndUserText.label: 'Utilization Rate' 0 as UtilizationRate } 

Query view uses cube view(ZEMH_I_EmployeeHours1) created previously as data source.

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:

2.7 1 5016314

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:

2.8 3 1578477

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:

2.11 1 7656036

In the above Odata service ID, TotaledProperties, Employee_NodeID, Employee_NodeIDExt, Employee_NodeText, Employee_ParentID, Employee_Level, Employee_Drillstate, Employee_Nodecount, Employee_T(Employee Text) , PlannedHours_F(PlannedHours Formatted), ActualHours_F(ActualHours Formatted), UtilizationRate_F(Utilization Formatted) attribute properties are generated automatically because of annotation define in the analytical query.

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

2.13 1 4245487

Enter Project Name:

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

2.15 1 9360873

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”:

2.17 1 8714090

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:

 "models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "ZHierarchy.i18n.i18n" } }, "": { "dataSource": "ZEMH_C_EMPLOYEEQUERY3_CDS" } },

Now View and Controller needs to be modified which displays hierarchy in the UI. I will continue this in the next blog Step 3. Smart TreeTable UI for Hierarchies

Your suggestions, feedback, comments on this blog are most welcome.

New NetWeaver Information at SAP.com

Very Helpfull

 

 

User Rating: Be the first one !