
ABAP Managed Database Procedure
Database Procedures are stored and executed in the Database. We can create and execute database procedures in HANA database through ABAP using AMDP Class and AMDP Method called ABAP Managed Database Procedures. SQL SCRIPT is the language for creating stored procedures in HANA. Main benefit of using SQL Script is to allow the execution of complex calculations inside HANA database. The language is varies from one database system to another.The ABAP Managed Database procedures should be created using ABAP Development Tools (Eclipse or HANA Studio).
Creation of ABAP Managed Database Procedure in ABAP
1. Open ABAP Development Tool ( Eclipse or HANA studio ) and Go to ABAP Perspective. Create new ABAP Class.
4. AMDP Class Definition
An AMDP is implemented in an AMDP class with a regular static method or instance method in any visibility section. The editing environment for AMDP is the ABAP class editor.
The AMDP class must contain the appropriate tag interface. IF_AMDP_MARKER_HDB is Marker Interface for DB Procedures.
Example:
a. In Class Definition provide interface IF_AMDP_MARKER_HDB.
b. Define the table type TT_ORDER and structure type TY_ORDER.
c. Define the method GET_SALESORDER_DETAILS (Method parameters should be Passed by value).
CLASS zcl_salesorder_details IMPLEMENTATION.
METHOD get_salesorder_details BY DATABASE PROCEDURE
FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING vbak vbap vbup.
*To get Sales Order details
et_order = SELECT vbak.vbeln,
vbap.posnr,
vbak.vkorg,
vbap.netwr as item_price,
CASE LFSTA
WHEN ' ' then 'Not Relevant'
WHEN 'A' then 'Not yet processed'
WHEN 'B' then 'Partially processed'
WHEN 'C' then 'Completely processed'
END AS status
FROM vbak AS vbak INNER JOIN vbap AS vbap
ON vbak.vbeln = vbap.vbeln
INNER JOIN vbup AS vbup
ON vbup.vbeln = vbap.vbeln AND vbup.posnr = vbap.posnr
WHERE vbak.vbeln = iv_vbeln;ENDMETHOD.
ENDCLASS.
Execute the ABAP Managed Database Procedure through Report
1. Create a New ABAP Program.
2. Provide Name and Description. Click on NEXT button.
3. Click on Finish button.
Output:
Provide the sales order number as the input
2. Database procedure will create in HANA DB at the first call of AMDP Method .
3. 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 'SAPABAP1'.
4. The Table Type 'TT_ORDER ' of AMDP Class will be stored as "ZCL_SALESORDER_DETAILS=>GET_SALESORDER_DETAILS=>P00000#ttyp"
5.The AMDP Method 'GET_SALESORDER_DETAILS' of AMDP Class
'ZCL_SALESORDER_DETAILS' will be stored as Database procedure
'ZCL_SALESORDER_DETAILS=>GET_SALESORDER_DETAILS' as shown below.
6. ZCL_SALESORDER_DETAILS=>GET_SALESORDER_DETAILS#stb2#20160831121018 and
ZCL_SALESORDER_DETAILS=>GET_SALESORDER_DETAILS#stub#20160831121018 are for calling Database procedure
"ZCL_SALESORDER_DETAILS=>GET_SALESORDER_DETAILS"
7. The database tables VBAK VBAP and VBUP are used in AMDP Method will be created as VIEWS in HANA Database system.
i) ZCL_SALESORDER_DETAILS=>VBAK#covw
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |