Monday 10 June 2019

Embedded CDS View exposure to Fiori

1. Introduction


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 :

1. Interface View

i. These views fetch the data and apply all the business logic in CDS views
ii. These views are further classified as Basic Views & Composite views

    1. Basic Views are the CDS views which directly fetch the data from Database mainly master data
    2. Composite Views are the CDS views which fetch mainly transactional data and do associations(Joins) and apply business logic

2. Consumption View

     1. These views use Interface views and connect to outer world
     2. It means, interface views are never expose to outer world which means our database is secure

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

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

2. Objective


Our objective is to display a Sales report at Fiori Dashboard.

Following are the steps

1. Create a Basic CDS views
2. Create Composite CDS Views
3. Create Consumption Views
4. Open Consumption view in Query Browser in Fiori Launchpad
5. Create Tile at Home screen for Sales Report

3. Development


1. CDS Views in Hana Studio

i. Create Material VDM Basic CDS View as follows:

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

2. Enter Name & Description, rest will  come by default

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

3. Next->Next->Select your TR ->Next

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

4. Write the logic as follows:

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

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:  

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

6.  Create Customer Country Name VDM Composite CDS View as follows

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

7. Create Sales-Customer VDM Composite CDS View as follows

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

8. Create Sales-Material VDM Composite CDS View as follows

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

9. Create CUBE VDM Composite CDS View as follows

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

10. Create Consumption CDS View as follows:

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

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

1. Login to Fiori

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

2. Search for Query Browser App

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

3. Open Query Browser app and search for your consumption CDS View

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

4. You will get you CDS view as

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

5. Double click on the CDS view you will get all the fields from CDS view and the annotations as well.

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

6. Select your CDS view and click on Open in Design Studio at the bottom right hand side

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

7. You will get the report as follows:

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

and also graphic presentation- Pie Chart, Bar Chart, etc.

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

8. You can use filter option as well

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

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

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

SAP ABAP CDS, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications, SAP ABAP Study Materials

No comments:

Post a Comment