AMDP Procedure – Accessing ABAP Data Types

light111AMDP Procedure – Accessing ABAP Data Types


AMDP Procedure method with AMDP macro to access abap data types

1

Report to test the amdp procedure.

2

Output.

3


AMDP Procedure:

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_amdp.

CLASS lcl_test_amdp DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODSrun.
ENDCLASS.
CLASS lcl_test_amdp IMPLEMENTATION.
  METHOD run.

* AMDP Method call
    TRY.
        IF cl_abap_dbfeatures=>use_featuresrequested_features VALUE #cl_abap_dbfeatures=>call_amdp_method )  abap_true.
          NEW zcl_demo_008_amdp)->get_spfli_detailsEXPORTING iv_mandt symandt 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).


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s