SAP 02-AMDP Functions for CDS Table Functions
  RdEelXhuDp09 2023年12月07日 22 0


1. 创建一个Core Data Service Table Functions

  • 新建 Core Data Service Table Functions
  • SAP 02-AMDP Functions for CDS Table Functions_AMDP


  • SAP 02-AMDP Functions for CDS Table Functions_Core_02


  • SAP 02-AMDP Functions for CDS Table Functions_AMDP_03

  • 定义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_COUNTRYFR:land1
                
returns {
            MANDT:abap.clnt;            //Field:ref elements
            CARRID:s_carr_id;
            CONNID:s_conn_id;
            COUNTRYFR:land1;
            CITYFROM:s_from_cit;
            AIRPFROM:s_fromairp;
            COUNTRYTO:land1;
            CITYTO:s_to_city;
            AIRPTO:s_toairp;
            FLTIME:s_fltime;
            DEPTIME:s_dep_time;
            ARRTIME:s_arr_time;
            DISTANCE:s_distance;
            DISTID:s_distid;
            FLTYPE:s_fltype;
            PERIOD:s_period;
}
implemented by method zamdp_demo_02=>GET_SPFLI_US;

SAP 02-AMDP Functions for CDS Table Functions_ci_04

2. 实现CDS Table Functions中的AMDP Class

  • 新建ABAP Class
  • 实现ABAP Class
CLASS zamdp_demo_02 DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    interfaces: IF_AMDP_MARKER_HDB.

    class-methods:
        GET_SPFLI_US
            for table function zamdp_cds_tabfunc_01.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zamdp_demo_02 IMPLEMENTATION.
    method GET_SPFLI_US by database function
                        for hdb language sqlscript
                        options read-only
                        using spfli.
      return  select
                t1.MANDT,
                t1.CARRID,
                t1.CONNID,
                t1.COUNTRYFR,
                t1.CITYFROM,
                t1.AIRPFROM,
                t1.COUNTRYTO,
                t1.CITYTO,
                t1.AIRPTO,
                t1.FLTIME,
                t1.DEPTIME,
                t1.ARRTIME,
                t1.DISTANCE,
                t1.DISTID,
                t1.FLTYPE,
                t1.PERIOD
            from spfli as T1
            where t1.mandt = :ip_clnt      --Use Table Function Parameter
                and t1.COUNTRYFR = :ip_COUNTRYFR;
    endmethod.
ENDCLASS.

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

  • ABAP中调用CDS Table Functions
SELECT *
  FROM zamdp_cds_tabfunc_01( ip_countryfr = 'US' )
  INTO TABLE @DATA(result) ##db_feature_mode[amdp_table_function].

cl_demo_output=>display( result ).
  • 运行效果


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月07日 0

暂无评论

RdEelXhuDp09