zoukankan      html  css  js  c++  java
  • 使用SAP Analysis Path Framework (APF)展示CDS view数据

    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:

    And this role has the following role menu assigned:

    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:


    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.

    Step2. Expose the created OData service via APF
    Click tile APF Configuration Modeler,

    Create a new Application:

    Use the default semantic object:

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

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

    And a new category:


    Select this new category and create a new step:

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

    Create a new Representation based on this step:

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

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


    Then choose the table representation:

    Then the table is displayed as expected:

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

    要获取更多Jerry的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    5 年,只为了一个更好的校验框架
    springboot 中 inputStream 神秘消失之谜
    没啥用的黑科技——自动生成测试对象信息框架
    投资中最简单的事
    一个提升英文单词拼写检测性能 1000 倍的算法?
    基于 junit5 实现 junitperf 源码分析
    关于 junit4 90% 的人都不知道的特性,详解 junitperf 的实现原理
    性能测试到底该怎么做?
    从代码生成说起,带你深入理解 mybatis generator 源码
    java 实现中英文拼写检查和错误纠正?可我只会写 CRUD 啊!
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13540517.html
Copyright © 2011-2022 走看看