共计 1155 个字符,预计需要花费 3 分钟才能阅读完成。
CLASS zcl_demo_001_amdp DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
METHODS: get_spfli_details EXPORTING VALUE(et_spfli) TYPE spfli_tab.
METHODS: get_spfli_details_amdp IMPORTING VALUE(iv_mandt) TYPE mandt
EXPORTING VALUE(et_spfli) TYPE spfli_tab.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_demo_001_amdp IMPLEMENTATION.
METHOD get_spfli_details.
SELECT * FROM spfli INTO TABLE et_spfli.
ENDMETHOD.
METHOD get_spfli_details_amdp BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING spfli.
et_spfli = SELECT * FROM spfli WHERE mandt = :iv_mandt;
ENDMETHOD.
ENDCLASS.
REPORT ztest_amdp.
CLASS lcl_test_amdp DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: run.
ENDCLASS.
CLASS lcl_test_amdp IMPLEMENTATION.
METHOD run.
* Normal Method call
NEW zcl_demo_001_amdp()->get_spfli_details( IMPORTING et_spfli = DATA(lt_spfli) ).
* AMDP Method call
TRY.
IF cl_abap_dbfeatures=>use_features(requested_features = VALUE #( ( cl_abap_dbfeatures=>call_amdp_method) ) ) = abap_true.
NEW zcl_demo_001_amdp( )->get_spfli_details_amdp( EXPORTING iv_mandt = sy-mandt
IMPORTING et_spfli = DATA(lt_spfli_amdp) ).
BREAK-POINT.
ENDIF.
CATCH cx_abap_invalid_param_value.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
lcl_test_amdp=>run().
正文完