关于abap:AMDP-过程-–-访问-ABAP-数据类型

42次阅读

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

CLASS zcl_demo_008_amdp DEFINITION PUBLIC FINAL CREATE PUBLIC .
  PUBLIC SECTION.
    TYPES: BEGIN OF ty_spfli,
             mandt     TYPE mandt,
             carrid    TYPE s_carr_id,
             connid    TYPE s_conn_id,
             countryfr TYPE land1,
             countryto TYPE land1,
           END OF ty_spfli.
    TYPES: tt_spfli TYPE TABLE OF ty_spfli.
    INTERFACES: if_amdp_marker_hdb.
    METHODS: get_spfli_details IMPORTING VALUE(iv_mandt) TYPE mandt
                               EXPORTING VALUE(et_spfli) TYPE tt_spfli.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_008_amdp IMPLEMENTATION.
  METHOD get_spfli_details BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY.
    DECLARE lt_spfli TABLE (mandt "$ABAP.type( SY-MANDT)",
                            carrid "$ABAP.type(S_CARR_ID)",
                            connid "$ABAP.type(S_CONN_ID)",
                            countryfr "$ABAP.type(LAND1)",
                            countryto "$ABAP.type(LAND1)" );
    lt_spfli.mandt[1] := '100';
    lt_spfli.carrid[1] := 'AA';
    lt_spfli.connid[1] := '1000';
    lt_spfli.countryfr[1] := 'DE';
    lt_spfli.countryto[1] := 'US';
    et_spfli = select * from :lt_spfli;
  ENDMETHOD.
ENDCLASS.
*&---------------------------------------------------------------------*
*& Report ztest_amdp5
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztest_amdp5.
CLASS lcl_test_amdp DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: run.
ENDCLASS.
CLASS lcl_test_amdp IMPLEMENTATION.
  METHOD run.

* AMDP Method call
    TRY.
        IF cl_abap_dbfeatures=>use_features(requested_features = VALUE #( ( cl_abap_dbfeatures=>call_amdp_method)  ) ) = abap_true.
          NEW zcl_demo_008_amdp( )->get_spfli_details( EXPORTING iv_mandt = sy-mandt
                                                       IMPORTING et_spfli = DATA(lt_spfli) ).
          BREAK-POINT.
        ENDIF.
      CATCH cx_abap_invalid_param_value.
    ENDTRY.

  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  lcl_test_amdp=>run().

正文完
 0