关于abap:做一个比较简单的cds串联amdp

49次阅读

共计 1615 个字符,预计需要花费 5 分钟才能阅读完成。

step one

step two

step three

code1
CLASS zcl_demo_flight_calculation DEFINITION PUBLIC FINAL CREATE PUBLIC .
 PUBLIC SECTION.
 INTERFACES: if_amdp_marker_hdb.
 CLASS-METHODS: get_details FOR TABLE FUNCTION ZDEMO_FLIGHT_CDS_TF.
 PROTECTED SECTION.
 PRIVATE SECTION.
ENDCLASS.



CLASS ZCL_DEMO_FLIGHT_CALCULATION IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_DEMO_FLIGHT_CALCULATION=>GET_DETAILS
* +-------------------------------------------------------------------------------------------------+
* +--------------------------------------------------------------------------------------</SIGNATURE>
 METHOD get_details BY DATABASE FUNCTION
                    FOR HDB
                   LANGUAGE SQLSCRIPT
                   OPTIONS READ-ONLY
                   USING spfli.
 RETURN
     SELECT mandt, carrid, connid,
            countryfr, cityfrom, airpfrom,
            countryto, cityto, airpto
           FROM spfli WHERE carrid = iv_carrid;
ENDMETHOD.
ENDCLASS.
code1


code 2
define table function zdemo_flight_cds_tf
with parameters  iv_carrid : s_carr_id
returns {
  mandt: s_mandt;
 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;

}
implemented by method zcl_demo_flight_calculation=>get_details;
code 2


code 3
*&---------------------------------------------------------------------*
*& Report zcds_with_if_amdp
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zcds_with_if_amdp.
SELECT *
         FROM zdemo_flight_cds_tf(iv_carrid = 'LH')
          INTO TABLE @DATA(lt_flight)
         ##db_feature_mode[amdp_table_function].
cl_demo_output=>display_data(EXPORTING value = lt_flight).
code 3

正文完
 0