zoukankan      html  css  js  c++  java
  • SAP CDS view自学教程之四:SAP CDS view注解@OData.publish的奥妙

    In part1 of this tutorial, the old way to create OData service on top of CDS view is introduced.
    In SAP Help Generate Service Artifacts From a CDS View a new annotation is described:

    @OData.publish: true

    Just add this annotation to your CDS view and the odata service is automatically created, no need for you to go to code SEGW any more.

    Once activated, the odata service with naming convention “_CDS” is available for registration in tcode /IWFND/MAINT_SERVICE:

    Metadata retrieval test ok:

    So the question here is: How does this annotation work? How can we research the service generation process through debugging?

    Here below is how I figure it out.
    First check what objects have been generated: three additional artifacts are highlighted below.

    (1) IWMO: SAP Gateway Business Suite Enablement – Model
    (2) IWSV: SAP Gateway Business Suite Enablement – Service
    (3) CLAS: provider class ZCL_ZJERRYTEST20160311 is generated

    If I remove the annotation, or change the annotation to @OData.publish: false, and the two are gone:

    So it means the annotation @OData.publish: true will trigger table entry insertion for type IWMO, IWSV and CLAS during view activation. Then again I switch on ST05 trace and easily find the ABAP code where the table insertion is done.

    Set breakpoint on the code and observe the callstack in the runtime.

    The highlighted callstack frames are essential for odata service generation.

    Let’s have a deep look at stack frame 21:
    CL_WB_DDLS_SECOBJ_HNDLR_SINGLE->IF_DDIC_WB_DDLS_SECOBJ_HANDLER~ON_ACTIVATION
    It will first identify which objects must be created based on delta state.

    For example, if I add @OData.publish: true to an existing CDS view and activate it, the corresponding entry will have flag N ( New ) while other existing annotation has type “U” ( Unchanged ).

    Inside this method, if annotation ODATA.PUBLISH is found,

    and the annotation value is true, then it is considered that the odata service must be created.



    The odata service creation is implemented in CL_SADL_GTK_ODATA_SERVICE_GEN~CREATE_VIA_EXPOSURE below.

    Complete callstack:

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

  • 相关阅读:
    【黑金原创教程】【FPGA那些事儿-驱动篇I 】实验二十六:VGA模块
    mini2440 u-boot下设置tftp
    mini2440 u-boot禁止蜂鸣器
    【转载】帧缓冲驱动程序分析及其在BSP上的添加
    debian7 amd64版本添加对x86包的支持
    debian7配置
    u盘安装debian 7(Wheezy) stabe
    【python练习题】实现字符串反转
    【python练习题】 删除列表中的重复元素(list的应用)
    【python练习题】冒泡排序 和插入排序 (list的应用)
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13638981.html
Copyright © 2011-2022 走看看