• SAP 02AMDP Functions for CDS Table Functions


    本文转载:https://blog.csdn.net/qq_30797051/article/details/123843806

    1. 创建一个Core Data Service Table Functions

      • 新建 Core Data Service Table Function

      • 定义CDS Table Functions

    @EndUserText.label: 'a simple AMDP for CDS Table Functions'
    @ClientDependent: true                              //打开 Open SQL 的自动客户端处理
    define table function ZAMDP_CDS_TABFUNC_01
    with parameters @Environment.systemField: #CLIENT   //Open SQL 通过将sy-mandt的值隐式传递给该参数来处理
                    ip_clnt:abap.clnt,       //入参client
                    ip_matnr:matnr
    returns {
      MANDT:abap.clnt;            //Field:ref elements
      MATNR:matnr;
      ERSDA:ersda;
      ERNAM:ernam;
      MTART:mtart;
      MATKL:matkl;
      SPRAS:spras;
      MAKTX:maktx;
    }
    implemented by method zamdp_demo002=>GET_MARA;

    2. 实现CDS Table Functions中的AMDP Class

    • 新建ABAP Class
    • 实现ABAP Class

      

    CLASS zamdp_demo002 DEFINITION
      PUBLIC
      FINAL
      CREATE PUBLIC .
    
    PUBLIC SECTION.
        interfaces: IF_AMDP_MARKER_HDB.
    
        class-methods:
            GET_MARA
                for table function zamdp_cds_tabfunc_01.
    PROTECTED SECTION.
    PRIVATE SECTION.
    ENDCLASS.
    
    
    
    CLASS zamdp_demo002 IMPLEMENTATION.
        method GET_MARA by database function
                        for hdb language sqlscript
                        options read-only
                        using mara makt.
    *可以多表连接  也可以单表查询                   
          return
            with makt_tmp as ( select * from makt )
            select  t1.MANDT,
                    t1.MATNR,
                    t1.ERSDA,
                    t1.ERNAM,
                    t1.MTART,
                    t1.MATKL,
                    t2.SPRAS,
                    t2.MAKTX
                from mara as t1
                inner join makt_tmp as t2 on t1.matnr = t2.matnr
                where t1.mandt = :ip_clnt      --Use Table Function Parameter
                  and t1.MATNR = :ip_matnr;
        endmethod.
    ENDCLASS.

    3. ABAP中调用AMDP Functions for CDS Table Functions

    • ABAP中调用CDS Table Functions
    *&---------------------------------------------------------------------*
    *& Report ZTMP_TEST_IT029
    *&---------------------------------------------------------------------*
    *&
    *&---------------------------------------------------------------------*
    REPORT ZTMP_TEST_IT029.
    
    
    START-OF-SELECTION.
      SELECT *
        FROM zamdp_cds_tabfunc_01( ip_matnr = '000000000100000001' )
        INTO TABLE @DATA(result) ##db_feature_mode[amdp_table_function].
    
      cl_demo_output=>display( result ).

  • 相关阅读:
    高效App运营必须get的七个推送技巧
    如何预测您的用户即将流失?
    HMS Core赋能移动金融,为行业注入增长新动力
    做好自定义预测,探寻产品增长动能
    Unity平台 | 快速集成华为AGC云数据库服务
    HMS Core Insights第一期直播回顾 – 深入浅出,创新技术与开发者共同推进行业发展!
    多种细分方式浏览销售数据,IAP助您有效洞察市场收益效果
    Unity | 快速集成华为AGC云存储服务
    awk命令
    反转字符串
  • 原文地址:https://www.cnblogs.com/seven1314pp/p/16092242.html
Copyright © 2020-2023  润新知