Skip to Content
Author's profile photo Jerry Wang

Step by step to visualize your CDS view via Analysis Path Framework (APF)

Analysis Path Framework (APF) is a framework which provides reuse components that allow you to build and enhance interactive analytical Web applications. Recently during my self study, I find out that an OData service exposed by CDS view could easily be consumed by APF.

Here below is detailed step.

For prerequisites to use APF, you can find it in SAP help.

In my case, I have the following PFCG role assigned:

/wp-content/uploads/2016/05/clipboard1_953820.png

And this role has the following role menu assigned:

/wp-content/uploads/2016/05/clipboard2_953821.png

Step1. Create a simple header and item CDS view, and a consumption view to expose as OData service.

Below source code is for item view:

@AbapCatalog.sqlViewName: 'zorITem'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'order item detail'
define view Z_I_Order_Item as select from zorder_item {
  key zorder_item.parent_id,
  key zorder_item.item_id,
  zorder_item.item_text
}
Below source code for header view:
@AbapCatalog.sqlViewName: 'zorheader'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'header view'
define view Z_I_Order_Header as select from zorder_header
association [0..*] to Z_I_Order_Item as _Item
on $projection.object_id = _Item.parent_id
{
  key zorder_header.object_id,
  zorder_header.description,
  @ObjectModel.association.type: #TO_COMPOSITION_CHILD
  _Item
}

The corresponding database in ABAP for these two CDS views are listed below:

/wp-content/uploads/2016/05/clipboard3_953840.png

/wp-content/uploads/2016/05/clipboard4_953841.png

The source code of CDS view:

@AbapCatalog.sqlViewName: 'zjorderview'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Jerry order consumption view'
@OData.publish: true
define view Z_C_Order as select from Z_I_Order_Header {
  key Z_I_Order_Header.object_id,
  Z_I_Order_Header.description,
  @ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
  Z_I_Order_Header._Item
}

Since I use the annotation OData.publish:true, so a corresponding OData service Z_C_Order_CDS is generated automatically.

Register it via tcode /IWFND/MAINT_SERVICE. Once done, ensure the metadata access could successfully be done.

/wp-content/uploads/2016/05/clipboard5_953842.png

Step2. Expose the created OData service via APF

Click tile APF Configuration Modeler,

/wp-content/uploads/2016/05/clipboard6_953846.png

Create a new Application:

/wp-content/uploads/2016/05/clipboard7_953847.png

Use the default semantic object:

/wp-content/uploads/2016/05/clipboard8_953848.png

Create a new configuration which acts as a container for sub settings such as Filters and Categories:

/wp-content/uploads/2016/05/clipboard9_953852.png

In Smart Filter, choose the OData service and entity type created from previous step.

/wp-content/uploads/2016/05/clipboard10_953853.png

And a new category:

/wp-content/uploads/2016/05/clipboard11_953854.png

/wp-content/uploads/2016/05/clipboard12_953858.png

Select this new category and create a new step:

/wp-content/uploads/2016/05/clipboard13_953859.png

In the step creation page, just select all the two properties exposed by CDS view Z_C_Order, that is:

/wp-content/uploads/2016/05/clipboard14_953860.png

Create a new Representation based on this step:

/wp-content/uploads/2016/05/clipboard15_953861.png

Here for representation type, I just choose the most simple one: Table. Choose property from drop down list for table display.

/wp-content/uploads/2016/05/clipboard16_953862.png

Once done, click execute button, you will see the following screen:

/wp-content/uploads/2016/05/clipboard17_953863.png

/wp-content/uploads/2016/05/clipboard18_953870.png

Then choose the table representation:

/wp-content/uploads/2016/05/clipboard19_953871.png

Then the table is displayed as expected:

/wp-content/uploads/2016/05/clipboard20_953872.png

Its content matches with the data in the corresponding database table.

/wp-content/uploads/2016/05/clipboard21_953873.png

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Needless to say ... Great blog !!

      I had a question on the Data Visualization options .. Does APF support the display of hierarchical data like a tree view ?

      I didn't find that in KPI Modeler either.

       

      Thanks.

      S

      Author's profile photo Emrah Özkan
      Emrah Özkan

      Hello,

      Is it possible to use chart representations in this case? I tried it, but I couldn't succeeded. When I choose a chart representation, for example column chart, the axis values come empty and there is no value to choose.

      BR,

      Emrah

      Author's profile photo Sergio Oliveira
      Sergio Oliveira

      Hello,

      First of all, you need a numeric field to do any kind of chart.The above example doesn't use any.

      I Just had a hard time trying to do this. APF would show me all chart types with an asterisk meaning I didn't have "enough measures" selected for a chart, even though I selected different fields from my service. Only table was available.

      Eventually realized I had to add a "@DefaultAggregation : #SUM" before my numeric fields in the CDS view, so APF would see it like an actual measure. Now it's working!