Calling AMDP Procedure from Another AMDP Procedure

light111Calling AMDP Procedure from Another AMDP Procedure


AMDP class with 2 AMDP Methods- One public and one private. The public AMDP Procedure method internally calls the private static AMDP procedure.

2

program that calls the public AMDP Procedure method[the call is just like the normal method call]

3

Output:

4


AMDP Class-

CLASS zcl_demo_002_amdp DEFINITION PUBLIC FINAL CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
METHODS: get_spfli_details_public IMPORTING VALUE(iv_mandt) TYPE mandt
                                                                    EXPORTING VALUE(et_spfli) TYPE spfli_tab.
PROTECTED SECTION.
PRIVATE SECTION.
CLASS-METHODS: get_spfli_details_private IMPORTING VALUE(iv_mandt) TYPE mandt
                                                                                     EXPORTING VALUE(et_spfli) TYPE spfli_tab.
ENDCLASS.
CLASS zcl_demo_002_amdp IMPLEMENTATION.
METHOD get_spfli_details_public BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zcl_demo_002_amdp=>get_spfli_details_private.
CALL “ZCL_DEMO_002_AMDP=>GET_SPFLI_DETAILS_PRIVATE”( iv_mandt => iv_mandt, et_spfli => et_spfli );
ENDMETHOD.

METHOD get_spfli_details_private 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-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_002_amdp)->get_spfli_details_publicEXPORTING 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