SAP S/4HANA Embedded Analytics - ERP Q&A https://www.erpqna.com Trending SAP Career News and Guidelines Thu, 11 Apr 2024 10:17:51 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 https://www.erpqna.com/wp-content/uploads/2021/11/cropped-erpqna-32x32.png SAP S/4HANA Embedded Analytics - ERP Q&A https://www.erpqna.com 32 32 Analytical Query CDS View creation and consumption in RSRT along with publishing OData Services https://www.erpqna.com/analytical-query-cds-view-creation-and-consumption-in-rsrt-along-with-publishing-odata-services/?utm_source=rss&utm_medium=rss&utm_campaign=analytical-query-cds-view-creation-and-consumption-in-rsrt-along-with-publishing-odata-services Thu, 11 Apr 2024 10:17:46 +0000 https://www.erpqna.com/?p=83314 Introduction In this blog you will learn about the creation of Query CDS Views for Analytical purpose and their consumption in RSRT tool, along with the required steps that needs to be followed to achieve it. Once after the Analytical query creation, I have tried replicating one of my project scenarios to have better understanding […]

The post Analytical Query CDS View creation and consumption in RSRT along with publishing OData Services first appeared on ERP Q&A.

]]>
Introduction

In this blog you will learn about the creation of Query CDS Views for Analytical purpose and their consumption in RSRT tool, along with the required steps that needs to be followed to achieve it. Once after the Analytical query creation, I have tried replicating one of my project scenarios to have better understanding on defining key figures/ measures in CDS views. In the end blog explains about the process needs to be followed to expose the given Query CDS view into OData service links. The Query CDS Views are created specifically for Analytical reporting purposes within SAP systems. They can be optimized for certain reporting scenarios, analytical queries, aggregations and further can be integrated with SAP FIORI tool providing much better visual reporting experience.

Creation of query CDS view:

For the creation of query CDS view we must follow 3 basic steps as mentioned below:

Screenshot1: Pictorial representation of Analytical Query CDS View

Steps to follow for the creation of query CDS view:

1. CDS Info Provider as source

We cannot use any standard R\3 DB tables as a source for the creation of Query CDS View. We can only use standard/existing CDS Views from the system that needs to be converted into CDS Info Provider. CDS Info Provider is called by the special annotation @Analytics.DataCategory: #CUBE. Here #CUBE means Info Provider. The significance of declaring your CDS View as cube because when we compare it with our BW terms, we will be creating report on top of Composite Provider, ADSO or Info Cube. Similarly, we need to convert our source CDS view as Info Provider to create the analytical report.

Screenshot2: Source CDS view

2. CDS Query view

Once after creation of CDS Info Provider view, create new CDS view by utilizing the source Info Provider CDS view as a data source which is ZCDS_CUBE from my context. Then start building our Query CDS View report as per the Business requirement and logic. Important annotations required for enabling the CDS as query view is @analytics.query: true and VDM.viewType: #CONSUMPTION. By declaring our CDS view as consumption CDS View, we will be able to derive all the required fields from our source CDS view without facing error.

Screenshot3: Creation of Query CDS View

Few important Annotations and their significance for the creation of the structure of our Query CDS View:

  • @AnalyticsDetails.query. axis: #ROWS – Used for defining attributes to row characteristics in Query Browser.
  • @AnalyticsDetails.query. axis: #COLUMN- Used for defining key figures to column in Query Browser.
  • @AnalyticsDetails.query. axis: #FREE – Used for defining attributes to Free characteristics in Query Browser.
  • @AnalyticsDetails.query. sortDirection: #DESC or #ASC – For sorting the values of the defined rows in Ascending or Descending order.
  • @AnalyticsDetails.query. display: #KEY_TEXT- Used for displaying the text of the key.
  • @AnalyticsDetails.query. totals: #HIDE – used for displaying the totals.
  • @AnalyticsDetails.query. formula: – To perform the calculations based on the Business requirements. We cannot see the formula calculations in data preview and can be displayed only when the query is processed in reporting tool.
  • @EndUser.text. label: – Can be used for labelling the new field that will be derived from Formula.
  • @consumption. filter.mandatory : True :- This annotation will give us prompts same as parameter.
  • @Aggregation.default: with this annotation domain, you can declare the required field as a measure.

3. CDS Consumption in RSRT

Two major stages involved in consuming the CDS View as Query in RSRT transaction as explained below:

a. For each Query CDS view created, first COMPU ID will be generated in RSRREPDIR backend table along with the Info Provider CDS View name under Info Cube field and query name in COMPID field as highlighted below. Provide the SQL view name of your CDS view with prefix 2C in COMPID tab and you will end up in the below screen as shown:

Screenshot4: RSREEPDIR Table view

b. One basic rule to consume the Query CDS view in RSRT Query monitor transaction. Use the prefix “2C+SQL view name” given in the CDS View.

Screenshot 5&6: Query monitor and Result view

Now let me try to explain you by replicating one of the issues I was facing in my project and thereby we will try to understand more about the the importance of Annotations related to Analytical report. In my source Info Provider CDS View ZCK_QUERY(structure provided below), I was calculating one field name called “calc” as shown below which populated the correct value as expected in the data preview.

Screenshot7: Source CDS view for “calc” field and data preview

But when I was trying to create report on top of this CDS View, the field “calc” had null values in the report, even after calling the required annotation as shown below.

Screenshot8: Query CDS View structure and output result view for field “calc”

After going through series of analysis and understanding on the basics of CDS View annotations, came to know that, as my field “calc” is measure/key figure in nature and values which got populated were not aggregated and thus causing error in my Query CDS View. In CDS View when such calculation happens on the key figure, it is necessary to declare the annotation @Aggregation.default: #SUM to derive the values from the source CDS View to Query CDS View.

Screenshot9: Corrected source CDS view and output result

Exposing CDS Query as OData Service:

One of my project requirements was to expose the query CDS View to OData service through sap gateway, so I got the opportunity to explore more about this OData services usage in CDS View and thought of sharing the required procedures in this platform.

Basically, OData Service is a standard web protocol used for querying and updating data present in SAP using ABAP/CDS. So, it is like a bridge between Backend to Front end systems like UI5/FIORI or any other integration systems. In this section let me try to explain to expose the given CDS View into OData service by activating the service link through Transaction code: /n/iwfnd/maint_service.

Usage of OData Annotation:

Declare the Annotation @OData.Publish: true in your CDS View as shown below and activate the CDS view.

Screenshot10: OData annotation declaration for Query CDS View

Once after the activation of CDS View, a popup will appear near the OData annotation comment declared, which will show as “Service is not active”.

Screenshot11: OData exposure popup

For the activation of OData service, get into the GUI system and follow the below mentioned steps:

1. Use the transaction code: /n/iwfnd/maint_service.

2. Click on the Add service tab in the Activate and Maintenance page.

Screenshot12: Add service tab

3. Fill the System Alias option with “1. LOCAL” and External Service Name option with the “2. CDS Entity name + _CDS” and click on the “3. Get Services”. In my case ZCDS_CONS is my CDS entity name, so my service name will be ZCDS_CONS_CDS which will appear under the tab “4. Technical Service Name”.

Screenshot 13: Add selected service view

4. Click on the service name been generated under the technical service name tab and provide the package assignment name as $TMP to store it locally where this service link will be generated. After providing the package name and then click on ok as highlighted below:

Screenshot14: Create package for the service

5. Next you will have the popup saying “Service XXX_CDS was created, and its metadata was loaded successfully”.

6. As a next step for the confirmation, come back to your ADT tool where you have called OData Annotation in your CDS View. Now the popup will show the OData service link for your CDS View as shown below:

Screenshot15: Activated OData service link reflecting in Query CDS view

7. Click on the OData -Service link and your OData server will appear like below:

Screenshot16: OData server image

8. To get OData service in SAP gateway client, use the option SAP gateway client option which is available in the maintenance service page. Here first search your activated OData CDS view with technical name and click on sap gateway client.

Screenshot17: SAP Gateway client

9. Once you enter the gateway client, click execute to display the OData service in gateway client.

Screenshot18: OData service in Gateway client

10. To display the meta data structure of your OData service, use the $metadata in the Request URI.

Screenshot19: Metadata structure view

The scope of these Query CDS views can be extended to display in SAP FIORI as well. For this you need to be aware of creating the UI5 App through UI annotations for Analytical Query CDS view.

Rating: 0 / 5 (0 votes)

The post Analytical Query CDS View creation and consumption in RSRT along with publishing OData Services first appeared on ERP Q&A.

]]>
SAP S/4HANA Embedded Analytics – From process to table https://www.erpqna.com/sap-s-4hana-embedded-analytics-from-process-to-table/?utm_source=rss&utm_medium=rss&utm_campaign=sap-s-4hana-embedded-analytics-from-process-to-table Thu, 26 May 2022 10:38:42 +0000 https://www.erpqna.com/?p=63432 In this blog post we will lay out the technical aspects of SAP S/4HANA Embedded Analytics, specifically how to get from a process to the apps and eventually the underlying CDS-views and tables. This is called data lineage. This information can be helpful when an issue arises in an app or the dataset needs to […]

The post SAP S/4HANA Embedded Analytics – From process to table first appeared on ERP Q&A.

]]>
In this blog post we will lay out the technical aspects of SAP S/4HANA Embedded Analytics, specifically how to get from a process to the apps and eventually the underlying CDS-views and tables. This is called data lineage. This information can be helpful when an issue arises in an app or the dataset needs to be adjusted or expanded.

When implementing SAP S/4HANA, the organization starts with capturing the processes. When the processes have been outlined, the corresponding S/4 reporting functionality can be found. There are three possible scenarios to do this:

1) The client uses a standard Fiori Analytical App (top flow)

2) The customer uses a (custom) Query (bottom flow)

3) Functionality is tailor-made

Depending on the scenario there is different method applicable to analyze the data lineage. The third scenario is not discussed in this blog post.

A graphical representation of the complete process is presented below.

Determine the process

We start by determining the process. To find the appropriate app we use the SAP Best Practices Explorer via https://rapid.sap.com/bp/. Click on SAP S/4HANA and then SAP Best Practices for SAP S/4HANA (on premise)‎. In menu item Solution Scope you will have the option to select the Scope Items per Line of Business. These Scope Items cover the standard processes as defined in SAP S/4HANA. For this blog post we will use Scope Item Procurement of Direct Materials (J45) as an example.

Get the Business roles

When opening the Scope Item, a description of the S4/HANA standard process is shown. This includes a document called Test script. In this document, the process of the Scope Item is described in detail including the business roles involved in the execution of this process. The Business Roles form the basis of what Fiori app is used for which part of the process. A user must be assigned a business role to use the Fiori Apps that fall within this Scope Item.

In the Test script you will find a chapter called Roles, in which the business roles of the process are shown. Logically, many of the roles within Procurement of Direct Materials are related to Purchasers, Inventory Managers and Accounts Payable Accountants, as you can see in the role description in the screenshot below.

Get the Fiori Analytical apps

Once the business roles within the scope item are known, the Fiori Apps that are included in this role can be requested. Since we are discussing Embedded Analytics, we focus on the Fiori Analytical Apps, the built-in Fiori apps aimed at reporting and analytics. In our example, the role of Purchaser (SAP_BR_PURCHASER) is used.

To find the Fiori Analytical Apps for the purchasing role, we can use the SAP Fiori Apps Reference Library via the link https://fioriappslibrary.hana.ondemand.com/sap/fix/externalViewer.

Click on All apps for SAP S/4HANA in the menu on the left side of the screen and select by Roles. At the top left a search bar will appear where a business role can be entered. As shown in the screenshot below, this role has 149 apps. Via the filter button, only the Analytical Type SAP Fiori – Analytical can be selected, after which only the reporting apps are shown. When selecting an app, more information about this Fiori Analytical app (read: report) is shown.

In this example, the analytical app Monitor Materials Without Purchase Contract was selected. When assigning the business role SAP_BR_PURCHASER to the user, this user can immediately start using this standard report which shows all materials without a purchase contract.

But where is the data in the report come from?

Look up the OData service of the Fiori app

To find the source data of an app, the first step is to find the name of the OData service. This can be done in two ways:

  1. via the Fiori Apps library
  2. via the app’s Manifest.json file.

Option 1 – via the Fiori Apps library

In the App Details of the Fiori app the OData service of the app can be found under Implementation information -> Configuration -> OData Service(s).

Option 2 – via the manifest.json file

If it is not listed in the Fiori App Library, the OData service can be found in the app’s manifest.json file. The technical name of the SAPUI5 application can be used for this.

Open the SAP GUI and start transaction SE80. Select BSP Application and enter the technical name of the SAPUI5 application. In section Page Fragments you will find the file manifest.json. The OData service can be found in the code of this file under “dataSources”. Please note, this option is available in the SAP S/4HANA on-premise and private cloud variant only.

Determining the CDS views of the OData service

Once we found the OData service that supplies the Fiori app with data, the underlying CDS views found as well. Depending on the naming convention of the OData Service, this can be done in three ways:

  1. OData service with suffix CDS
  2. suffix _SRV
  3. prefix CB

1. OData service <xxxx>_CDS

Take the name of the OData service without the suffix _CDS.

The Data Definition of this can be found in Eclipse. Please note, this is only possible in the SAP S/4HANA on-premise or private cloud variant.

2. OData service <xxxx>_SRV

For the OData services with naming convention _SRV, an additional step is required. First step is to take the OData service without the suffix _SRV.

Open the SAP GUI, go to the SAP Gateway Service Builder (transaction SEGW) and open the OData service. This shows the data model of the OData service. Click on the hierarchy to show the Entity Types this will show the CDS views. Copy the technical name of the CDS view without the suffix Type and you can find the CDS view in Eclipse. This step is also only possible in SAP S/4HANA on-premise or private cloud.

3. OData service CB_<xxxxx>

To retrieve the underlying CDS views of an OData service with naming convention CB_, the first step is to go to transaction /IWFND/MAINT_SERVICE in the SAP GUI. The OData service can be searched via the filter button. When found, select the service, and click Service Implementation at the bottom right.

Open the Data Provider class.

Go to the method GET_ENTITYSET and search within the ABAP code for the technical names of the CDS views.

Other OData services

If you have an OData service that does not fall within these naming conventions, there is another way to determine the underlying CDS views. To do this, go to transaction /IWFND/MAINT_SERVICE again and click on Service Implementation. This time, open the Model Provider Class.

Search within the class for the method IF_SADL_GW_MODEL_EXPOSURE_DATA~GET_MODEL_EXPOSURE.

Search in the code for dataSource type=”CDS” and after binding= you will find the names of the CDS views.

This is the data lineage process of a Fiori Analytical app to the CDS views. But what if it is not a standard Fiori app that is used, but a query?

Determine the Query

Open the Query Browser app in SAP S/4HANA and type in a keyword of the data you are looking for, like Product. The Query Browser now lists all queries that have product in the view name.

Get the CDS view

When the query is found, the underlying views can be retrieved in the SAP S/4HANA app View Browser. Since the query itself is also a view, the technical name of the query can be looked up directly. A query is always of View Type Consumption.

Click on the view and select the Cross reference tab to see the CDS views.

Another way, only available for SAP S/4HANA on-premise and private cloud, is to search for the technical name of the query view directly in Eclipse.

Get the table(s)

Finding the CDS view is not the end of our journey. CDS views often take data from other CDS views, that in turn read their data from SAP source tables. To get an overview of the relations between various CDS views and source tables the Dependency Analyzer can be used.

This is done by searching for the CDS view in eclipse. By right clicking in the code, you can select Open with a Dependency Analyzer.

Rating: 0 / 5 (0 votes)

The post SAP S/4HANA Embedded Analytics – From process to table first appeared on ERP Q&A.

]]>
Usage of UI Annotations in CDS views and Business Application Studio https://www.erpqna.com/usage-of-ui-annotations-in-cds-views-and-business-application-studio/?utm_source=rss&utm_medium=rss&utm_campaign=usage-of-ui-annotations-in-cds-views-and-business-application-studio Thu, 14 Apr 2022 03:13:45 +0000 https://www.erpqna.com/?p=61898 Now a days client has plenty of choices to select Analytical tools as per there business requirements and budget. Cloud being most popular option most of clients are preferring cloud solutions so that they don’t need to invest time in maintaining environments and installations. With Wide adaption of SAP intelligent Enterprise SAP has introduce Business […]

The post Usage of UI Annotations in CDS views and Business Application Studio first appeared on ERP Q&A.

]]>
Now a days client has plenty of choices to select Analytical tools as per there business requirements and budget. Cloud being most popular option most of clients are preferring cloud solutions so that they don’t need to invest time in maintaining environments and installations.

With Wide adaption of SAP intelligent Enterprise SAP has introduce Business Application studio as a part of BTP as next generation for Web IDE. Developed for efficient development for business applications like Fiori, SAP Mobile Services, SAP Cloud Business Applications, SAP Fiori Elements, SAP S4HANA Extensions, Modelling and modelling work flows etc.

SAP Business Application Studio is an SAP Business Technology Platform service in the Cloud Foundry environment. It is built on open-source and leading industry standards and supports a modular approach to developing different kinds of apps.

To Model all these applications SAP offers Dev spaces which are like isolated virtual machines in the cloud. Each Dev space contains table tools and pre installed runtime sets which help in save time to setup dev environment, required 0 installation and maintenance.

Even though there are multiple Reporting tools available in SAP and Non SAP space like SAC, Power BI , tableu etc Fiori is mostly choose for embedded analytics reporting if client does not want to invest on additional tools and wanted to have unified view for reporting requirements. Even though Fiori has limitations in Reporting, using Analytical List pages lot of reporting requirements can be met. Using ALP provides ability to create an analytical dashboard with KPIs, charts, tables and also a drill-down navigation to a detail page.

ALP can be created using Manager KPI and Reports in Fiori applications but in case of any customizations and special requirement it might not work as expected. So business application studio can be used in such cases to customise Fiori apps. Report design can be divided between front end and back end. Here CDS is backend and Fiori is front end. Front end report design can be done in BAS (previously Web IDE) but it needs lot of customised coding in Java/XML etc but it is recommend to push maximum possible coding in CDS including Fiori front end design which can be achieved by UI annotations. Minimum code is required in BAS or very specific front end design which is not possible with CDS.

I will take an example to design and build ALP using CDS UI Annotations and Business Application Studio

ALP Report design has 3 sections

  • Page Title
  • Page Header
  • Page Content

Page Title – Here can define page header and KPI’s

Below is sample CDS code to define Header using UI annotations in CDS

@UI: {
headerInfo: {
typeName:       'Report Title',
typeNamePlural: 'Report Title',
title: {
value: 'Report Title'
},
description:    { value: 'Report Title' }
}
}

This section also contains KPI tags and further can drill down to KPI Cards once you click on KPI which can further show some overview charts (if required). You can define these KPI and even highlight based on colours which can be defined by CDS annotations. In BAS just need to call KPI Indicators (which will be explained in BAS steps)

For KPI define below variants for in CDS view

First define SelectionPresentationVariant then PresentationVariant and then you can define Datapoint or Chart as per your requirement. In my case I will define just Data Point.

As I have 2 KPI’s I have to define 2 Qualifiers for KPI. ALP looks for SelectionPresentationQualifier if not found it looks for Presentation qualifier so it is better to define it in CDS and select it BAS

@UI.presentationVariant: [{
       qualifier: 'KPIPOQualifier',
       text: 'KPI: KPIPOQualifier',
       visualizations: [{
           type: #AS_DATAPOINT,
           qualifier: 'KPIPOQualifier'
                        }]
                        },
        {
       qualifier: 'KPILineQualifier',
       text: 'KPI: KPILineQualifier',
       visualizations: [{
         type: #AS_DATAPOINT,
         qualifier: 'KPILineQualifier'
         }]
      }

Once you define SelectionPresentationQualifier in this step you have to define name of presentatiovariantqualifier as well as selection variant qualifiers name. In the next step we will define presentationvariant qualifiers where we can define Data point or chart with qualifier name

Next step is to define SelectionVariant qualifier

@UI.selectionVariant: [{
     qualifier: 'KPIPOQualifier',
     text: 'Default'
        },
        {
       qualifier: 'KPILineQualifier',
       text: 'Default'
        },
                ]

UI Annotations are defined above CDS view definition. How CDS will know which field is data point so inside define View section of CDS you need to define data point as below

@UI: {
dataPoint: {
title: 'PO',
valueFormat.numberOfFractionalDigits: 0,
minimumValue: 0,
maximumValue: 100,
criticalityCalculation: {
improvementDirection: #MAXIMIZE,
deviationRangeLowValue: 70,
toleranceRangeLowValue: 84
}
}
}
@AnalyticsDetails.query.axis: #COLUMNS
@AnalyticsDetails.query.decimals: 0
@EndUserText.label: 'KPIPOQualifier'
@AnalyticsDetails.query.formula: 'NDIV0( NODIM( $projection.KPI) / NODIM( $projection.Total))*HundredPercent '
1 as KPIPOQualifier,

@UI: {
dataPoint: {
title: 'LI',
valueFormat.numberOfFractionalDigits: 0,
minimumValue: 0,
maximumValue: 100,
criticalityCalculation: {
improvementDirection: #MAXIMIZE,
deviationRangeLowValue: 70,
toleranceRangeLowValue: 84
}
}
}

@AnalyticsDetails.query.axis: #COLUMNS
@AnalyticsDetails.query.decimals: 0
@EndUserText.label: 'KPILineQualifier'
@AnalyticsDetails.query.formula: 'NDIV0( NODIM( $projection.KPILi) / NODIM( $projection.TotalLine))*HundredPercent'
1 as KPILineQualifier

Page Header

ALP has 2 types of filters Compact Filter and Visual Filters. To define Compact filter you need to just define @UI.SelectionFields annotation

To define Visual filters need to define PresentationVariant and charts in CDS first and call those qualifiers in BAS

There are 3 visual filters in this example

Define filter qualifiers in PresentationVariant and visualization will be chart

@UI.presentationVariant: [{ {
qualifier: 'FilterMiss',
text: 'Filter: Miss',
visualizations: [{
type: #AS_CHART,
qualifier: 'ChartMiss'
}]
},
{
qualifier: 'FilterTime',
text: 'Filter: Time',
visualizations: [{
type: #AS_CHART,
qualifier: 'ChartTime'
}]
}, {
qualifier: 'FilterContract',
text: 'Filter: Contract',
visualizations: [{
type: #AS_CHART,
qualifier: 'ChartContract'
}]
},

Now define Dimension and measures used in the charts and type of chart in @UI.Chart annotation

@UI.chart: [{​​​​​
qualifier: 'ChartMiss',
chartType: #BAR,
dimensions:  [ 'OnTimePO' ],
measures:  [ 'CountPO' ],
dimensionAttributes: [{​​​​​
dimension: 'OnTimePO',
role: #CATEGORY
}​​​​​],
measureAttributes: [{​​​​​
measure: 'CountPO',
role: #AXIS_1
}​​​​​]
}​​​​​,
{​​​​​
qualifier: 'ChartTime',
chartType: #BAR,
dimensions:  [ 'FullIndicator' ],
measures:  [ 'CountPO' ],
dimensionAttributes: [{​​​​​
dimension: 'FullIndicator',
role: #CATEGORY
}​​​​​],
measureAttributes: [{​​​​​
measure: 'CountPO',
role: #AXIS_1
}​​​​​]
}​​​​​,
{​​​​​
qualifier: 'ChartContract',
chartType: #BAR,
dimensions:  [ 'Status' ],
measures:  [ 'CountPO' ],
dimensionAttributes: [{​​​​​
dimension: 'Status',
role: #CATEGORY
}​​​​​],
measureAttributes: [{​​​​​
measure: 'CountPO',
role: #AXIS_1
}​​​​​]
}​​​​​,

Page Content

Page content has 2 sections chart and table. In this chart only or table only view also available. Need to define below variants for chart and tables

Below is main chart for which needs to define PresentationVariant and then Chart annotations

For Content chart define qualifier under @UI.selectionPresentationVariant to call PresentationVariant and SelectionVariant qualifiers

{
qualifier: 'Default',
presentationVariantQualifier: 'Default',
selectionVariantQualifier: 'Default'
}

And define chart as type and chart qualifier in @UI.presentationVariant

{
qualifier: 'Default',    //Qualifier for ALP content chart section (chart above)
visualizations: [{
type: #AS_CHART,
qualifier: 'ChartDefault'
}]
}
]

Below will define chart dimensions and measures using @UI.Chart

qualifier: 'ChartDefault',
chartType:#COLUMN,
dimensions:  [ 'YearMonth' ],
measures:  [ 'PO','Line','MissPer'],
dimensionAttributes: [{​​​​​
dimension: 'YearMonth',
role: #CATEGORY
}​​​​​],
measureAttributes: [{​​​​​
measure: 'MissPer',
role: #AXIS_2
}​​​​​,
{​​​​​
measure: 'Line',
role: #AXIS_1
}​​​​​,
{​​​​​
measure: 'PO',
role: #AXIS_1
}​​​​​
]
}​​​​​
]

For Table just need to define LineItem in CDS

@UI.lineItem.position: 10
Purchase Order ID

After defining variants in CDS you need to call these qualifiers in BAS. Before doing that you need to create a Project in BAS.

Open BAS URL and login to Space and click on Project From template

Define name of App and Click on Finish

Once project is created in BAS . you need to open workspace and Project then in editor will get web app files like Annotations.xml and Manifest.json files . In these files you need to call various qualifiers and define some code

Now the KPI’s defined in CDS UI annotations need to be called in BAS. Open Manifest.json file and search KeyPerformanceIndicators

"keyPerformanceIndicators": {

"POQualifier": {

"model": "kpiModel",

"entitySet": "CDS View NAME",             // Name of CDS view

"qualifier": "POQualifier"

},

"LineQualifier": {

"model": "kpiModel",

"entitySet": "CDS View NAME",             // Name of CDS view

"qualifier": "LineQualifier"

}

Do not forget to refresh mainService

In Preview Application now KPI tags will be added

Check Annotation.xml file in BAS and update field details

<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">

<edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/Common.xml">

<edmx:Include Namespace="com.sap.vocabularies.Common.v1" Alias="Common" />

</edmx:Reference>

<edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/UI.xml">

<edmx:Include Namespace="com.sap.vocabularies.UI.v1" Alias="UI" />

</edmx:Reference>

<edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/Communication.xml">

<edmx:Include Namespace="com.sap.vocabularies.Communication.v1" Alias="Communication" />

</edmx:Reference>

<edmx:Reference Uri="/sap/opu/odata/sap/CDS View Name/$metadata">

<edmx:Include Namespace=" CDS View Name " Alias="SAP" />

</edmx:Reference>

<edmx:DataServices>

<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="com.xx.ri11.xxxx">

<Annotations Target="SAP. CDS View NameType">

<Annotation Term="UI.SelectionFields">

<Collection>

<!-- remove/comment CreationDate or DateRangeCustomFilter.fragment.xml won't work!

<PropertyPath>CreationDate</PropertyPath> -->

<PropertyPath>Supplier</PropertyPath>

<PropertyPath>OnTimePO</PropertyPath>

<PropertyPath>FullIndicator</PropertyPath>

<PropertyPath>Status</PropertyPath>

<PropertyPath>MatGroup</PropertyPath>

</Collection>

</Annotation>

<Annotation Term="UI.KPI" Qualifier="POQualifier">

<Record>

<PropertyValue Property="DataPoint" Path="@UI.DataPoint#KPIPOQualifier" />

<PropertyValue Property="SelectionVariant" Path="@UI.SelectionVariant#KPIPOQualifier" />

<PropertyValue Property="ID" String="POQualifier" />

<PropertyValue Property="Detail">

<Record Type="UI.KPIDetailType">

<PropertyValue Property="SemanticObject" String="test" />

<PropertyValue Property="Action" String="test" />

<PropertyValue Property="DefaultPresentationVariant" Path="@UI.PresentationVariant#KPIPOQualifier" />

</Record>

</PropertyValue>

</Record>

</Annotation>

<Annotation Term="UI.KPI" Qualifier="LineQualifier">

<Record>

<PropertyValue Property="DataPoint" Path="@UI.DataPoint#KPILineQualifier" />

<PropertyValue Property="SelectionVariant" Path="@UI.SelectionVariant#KPILineQualifier" />

<PropertyValue Property="ID" String="LineQualifier" />

<PropertyValue Property="Detail">

<Record Type="UI.KPIDetailType">

<PropertyValue Property="DefaultPresentationVariant" Path="@UI.PresentationVariant#KPILineQualifier" />

</Record>

</PropertyValue>

</Record>

</Annotation>

</Annotations>

<Annotations Target="SAP. CDS View Name Type/Status">

<!-- Annotation WITHOUT QUALIFIER for Compact Filter, supplied by Backend(CDS) already-->

<!-- Annotation WITH QUALIFIER for Visual Filter -->

<Annotation Term="Common.ValueList" Qualifier="ChartMiss">

<Record Type="Common.ValueListType">

<PropertyValue Property="CollectionPath" String=" CDS View Name " />

<PropertyValue Property="PresentationVariantQualifier" String="FilterContract" />

<PropertyValue Property="Parameters">

<Collection>

<Record Type="Common.ValueListParameterInOut">

<PropertyValue Property="LocalDataProperty" PropertyPath="Status" />

<PropertyValue Property="ValueListProperty" String="Status" />

</Record>

</Collection>

</PropertyValue>

</Record>

</Annotation>

</Annotations>

<Annotations Target="SAP. CDS View Name Type/OnTimePO">

<!-- Annotation WITHOUT QUALIFIER for Compact Filter, , supplied by Backend(CDS) already -->

<!-- Annotation WITH QUALIFIER for Visual Filter -->

<Annotation Term="Common.ValueList" Qualifier="ChartMiss">

<Record Type="Common.ValueListType">

<PropertyValue Property="CollectionPath" String=" CDS View Name " />

<PropertyValue Property="PresentationVariantQualifier" String="FilterMiss" />

<PropertyValue Property="Parameters">

<Collection>

<Record Type="Common.ValueListParameterInOut">

<PropertyValue Property="LocalDataProperty" PropertyPath="OnTimePO" />

<PropertyValue Property="ValueListProperty" String="CountPO" />

</Record>

</Collection>

</PropertyValue>

</Record>

</Annotation>

</Annotations>

<Annotations Target="SAP. CDS View Name Type/FullIndicator">

<Annotation Term="Common.ValueList" Qualifier="ChartTime">

<Record Type="Common.ValueListType">

<PropertyValue Property="CollectionPath" String=" CDS View Name " />

<PropertyValue Property="PresentationVariantQualifier" String="FilterTime" />

<PropertyValue Property="Parameters">

<Collection>

<Record Type="Common.ValueListParameterInOut">

<PropertyValue Property="LocalDataProperty" PropertyPath="FullIndicator" />

<PropertyValue Property="ValueListProperty" String="CountPO" />

</Record>

</Collection>

</PropertyValue>

</Record>

</Annotation>

</Annotations>

</Schema>

</edmx:DataServices>

</edmx:Edmx>

Finally once you run the ALP app from preview you will get below output

This BAS code can be downloaded and published on cloud and can be added as Fiori tile for end user.

Rating: 0 / 5 (0 votes)

The post Usage of UI Annotations in CDS views and Business Application Studio first appeared on ERP Q&A.

]]>