Embedded CDS View exposure to Fiori
As we are aware that in SAP S/4HANA system, most of the DDIC tables has been converted to CDS views or DDL SQL Views. SAP is trying to mold all the technical changes/ABAP using these CDS views.
Now question is, how to expose our custom CDS views to Fiori Launchpad without UI5 developer.
Solution is simple, VDM i.e. Virtual Data Model.
VDM consist of two type of views :
- Interface View
- These views fetch the data and apply all the business logic in CDS views
- These views are further classified as Basic Views & Composite views
- Basic Views are the CDS views which directly fetch the data from Database mainly master data
- Composite Views are the CDS views which fetch mainly transactional data and do associations(Joins) and apply business logic
- Consumption View
- These views use Interface views and connect to outer world
- It means, interface views are never expose to outer world which means our database is secure
Now next question is ..How to figure out which CDS view to set as basic view or composite view or consumption view.
ANNOTATIONS…are the key
SAP has provided lots of annotations which can be understood by any other platforms such as OData services, BI, Fiori, etc.
Annotation is a set of strings connected with DOT e.g. @EndUserText.label @VDM.viewType These are quite self-explanatory, we will see it in later section
Our objective is to display a Sales report at Fiori Dashboard.
Following are the steps
- Create a Basic CDS views
- Create Composite CDS Views
- Create Consumption Views
- Open Consumption view in Query Browser in Fiori Launchpad
- Create Tile at Home screen for Sales Report
CDS Views in Hana Studio
- Create Material VDM Basic CDS View as follows:
- 2. Enter Name & Description, rest will come by default
- 3. Next->Next->Select your TR ->Next
- 4. Write the logic as follows:
Here we are using Annotations. Following are the details for main annotations: @VDM.viewType- This annotation represent the CDS exposure type. It has mainly 3 types: - #BASIC – Expose to internal CDS views only, similar to PRIVATE section in our CLASSES - #COMPOSITE - Expose to internal CDS views only and uses #BASIC CDS views, similar to PRIVATE section in our CLASSES - #COMSUMPTION - Exposed to external platform such as OData, Fiori, and BW. It uses only #BASIC & #COMPOSITE CDS views @Analytics.dataCategory-This annotation represent the data type. It has mainly 3 types: - #DIMENSION - It means this CDS view it accessing master data - #FACT – It means this CDS view is accessing only transactional data - #CUBE – It means this CDS view has joins/associations of the #FACT CDS views and sometimes with #DIMENSION CDS views as well
5. Create Customer VDM Basic CDS View as follows:
6. Create Customer Country Name VDM Composite CDS View as follows
7. Create Sales-Customer VDM Composite CDS View as follows
8. Create Sales-Material VDM Composite CDS View as follows
9. Create CUBE VDM Composite CDS View as follows
10. Create Consumption CDS View as follows:
Here we are using other Annotations. Following are the details for main annotations: @Analytics.query- This annotation represent that it is an analytic CDS view @OData.publish- This annotation makes this CDS view available for OData services @Consumption.filter- This annotation set the filter property for the particular field
4.2 Deployment in Fiori Launchpad
- Login to Fiori
2. Search for Query Browser App
3.Open Query Browser app and search for your consumption CDS View
4.You will get you CDS view as
5.Double click on the CDS view you will get all the fields from CDS view and the annotations as well.
6.Select your CDS view and click on Open in Design Studio at the bottom right hand side
7. You will get the report as follows:
and also graphic presentation- Pie Chart, Bar Chart, etc.
8. You can use filter option as well
9. We can save this report as tile in our dashboard as follows:
At the bottom right hand side, click on icon and select Save as Tile
With help of embedded analytics user can get the run-time data as good as Live data.
Using embedded CDS views, we can leverage the benefit of S/4HANA’s strong analytic capabilities and Fiori’s UX.