• 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 ).

  • 相关阅读:
    坑爹啊 StringDictionary 居然是不区分大小写的
    .NET平台OLEDB类型映射到Access数据类型 (转)
    国内省选乱做
    计算几何做题记录
    P6634 [ZJOI2020] 密码 解题报告
    AT2704 [AGC019E] Shuffle and Swap 解题报告
    ARC110F Esoswap 解题报告
    P6631 [ZJOI2020] 序列 解题报告
    P6633 [ZJOI2020] 抽卡 解题报告
    CF1605F PalindORme 解题报告
  • 原文地址:https://www.cnblogs.com/seven1314pp/p/16092242.html
Copyright © 2020-2023  润新知