AMDP Function Method

light111AMDP Function Method with sqlscript


AMDP Procedure method and AMDP function method .

The procedure method can not have any return parameter and the function method must have a return parameter.

1

Report to test amdp procedure.

2

Call only made to the AMDP procedure method.

3

A call can be made to the AMDP function method and there would be no syntax error from abap program but the execution dump at runtime. So AMDP function method must not be called from any abap program or any normal method but it must be called from another amdp procedure method.

45


AMDP class with procedure and fnction:

CLASS zcl_demo_007_amdp DEFINITION PUBLIC FINAL CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES: if_amdp_marker_hdb.
METHODS: get_spfli_details_dp IMPORTING VALUE(iv_mandt) TYPE mandt
                                                                                      VALUE(iv_carrid) TYPE spfli-carrid
                                                              EXPORTING VALUE(et_spfli) TYPE spfli_tab.
METHODS: get_spfli_details_df IMPORTING VALUE(iv_mandt) TYPE mandt
                                                                                    VALUE(iv_carrid) TYPE spfli-carrid
                                                             RETURNING VALUE(rt_spfli) TYPE spfli_tab.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_007_amdp IMPLEMENTATION.

METHOD get_spfli_details_dp BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zcl_demo_007_amdp=>get_spfli_details_df.
et_spfli = SELECT * FROM “ZCL_DEMO_007_AMDP=>GET_SPFLI_DETAILS_DF”( IV_MANDT => IV_MANDT, IV_CARRID => IV_CARRID );
ENDMETHOD.

METHOD get_spfli_details_df BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING spfli.
RETURN SELECT * FROM spfli WHERE mandt = :iv_mandt AND carrid = :iv_carrid;
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 cl_abap_dbfeatures=>amdp_table_function abap_true.
          NEW zcl_demo_007_amdp)->get_spfli_details_dpEXPORTING iv_mandt symandt iv_carrid ‘AA’ 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).


 

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 )

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