AMDP Procedure Methods with Inheritance

light111AMDP Procedure Methods with Inheritance


Abstract Super Class with AMDP Marker Tag Interface.

1

Subclass with AMDP Procedure Method redefining the abstract method of super class.

2

Subclass with normal method redefining the abstract method of super class.

3

Report to test.

4

Output:

5


Abstract Super Class-

CLASS zcl_demo_003_amdp DEFINITION PUBLIC CREATE PUBLIC ABSTRACT.

PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
METHODS: get_spfli_details ABSTRACT IMPORTING VALUE(iv_mandt) TYPE mandt
                                                                             EXPORTING VALUE(et_spfli) TYPE spfli_tab.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_003_amdp IMPLEMENTATION.
ENDCLASS.


Subclass with AMDP ProcedureMethod

CLASS zcl_demo_004_amdp DEFINITION PUBLIC
INHERITING FROM zcl_demo_003_amdp FINAL CREATE PUBLIC .

PUBLIC SECTION.
METHODS: get_spfli_details REDEFINITION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_004_amdp IMPLEMENTATION.
METHOD get_spfli_details BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING spfli.
et_spfli = SELECT * FROM spfli WHERE mandt = :iv_mandt;
ENDMETHOD.
ENDCLASS.


Subclass with normal redefined method

CLASS zcl_demo_005_amdp DEFINITION PUBLIC INHERITING FROM zcl_demo_003_amdp FINAL CREATE PUBLIC .

PUBLIC SECTION.
METHODS get_spfli_details REDEFINITION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_005_amdp IMPLEMENTATION.
METHOD get_spfli_details .
SELECT * FROM spfli INTO TABLE et_spfli.
ENDMETHOD.
ENDCLASS.


REPORT ztest_amdp.

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

    NEW zcl_demo_005_amdp)->get_spfli_detailsEXPORTING iv_mandt symandt IMPORTING et_spfli DATA(lt_spfli).
* AMDP Method call
    TRY.
        IF cl_abap_dbfeatures=>use_featuresrequested_features VALUE #cl_abap_dbfeatures=>call_amdp_method abap_true.
          NEW zcl_demo_004_amdp)->get_spfli_detailsEXPORTING iv_mandt symandt 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).


 

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