In this First AMDP Program will create AMDP class and call AMDP class into the Report program.
Create AMDP Class
Ø Step 1: Create Global class
Ø Step 4: Define Static Method, Importing/
Exporting parameter should be pass by value and add “BY DATABASE PROCEDURE FOR
HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING VBAK” for make AMDP method.
Note: Define structure field name must be same name of the AMDP method exporting field name.
AMDP Class Code:
CLASS zcl_amdp_demo_class DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
"Add AMDP Class Interface
INTERFACES if_amdp_marker_hdb.
"Define Structure
TYPES: BEGIN OF lty_output,
SalesOrder TYPE vbeln_va,
OrderDate TYPE audat,
OrderType TYPE auart,
SalesOrg TYPE vkorg,
DistChannel TYPE vtweg,
Division TYPE spart,
END OF ltY_OUTPUT.
"Define table type
TYPES tt_output TYPE TABLE OF lty_output.
"Static AMDP Method
CLASS-METHODS: get_data IMPORTING VALUE(iv_mandt) TYPE mandt
EXPORTING VALUE(et_output) TYPE tt_output.
ENDCLASS.
CLASS zcl_amdp_demo_class IMPLEMENTATION.
METHOD get_data BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING vbak.
et_output = select vbeln as SalesOrder,
audat as OrderDate,
auart as OrderType,
vkorg as SalesOrg,
vtweg as DistChannel,
spart as Division
from vbak
where mandt = :iv_mandt;
ENDMETHOD.
ENDCLASS.
Call AMDP Class to Report:
Ø Note: When we first call AMDP Method
then Database procedure will be created in HANA DB. To check the procedure in
HANA DB follow the below process:
- Step 1: Check the DB connection
using Transaction code: DBACOCKPIT
- Step 2: Go to SAP HANA Development perspective=> HANA DB System =>Catalog =>Schema =>Procedures.
§ The AMDP Method Implementation will be stored as Database procedure
and Table Types of AMDP Class also stored under Schema 'SAPASP'.
No comments:
Post a Comment