Tuesday 2 November 2021

ABAP Managed Database procedures with SELECT OPTIONS

The ABAP ON HANA Technology provides a great advantage to developers to push down the logic at database level. ABAP Managed Database Procedures (AMDP) was introduced in Release 7.40, SP05. since its introduction by sap there is huge progress in the development of objects in Hana as well as in ABAP platform.

ABAP ON HANA Technology increases the performance with its code to data paradigm and provides the much capabilities at HANA Level. The introduction of CDS view and AMDP are major concepts that uses the SQL script capabilities which the database understands.

AMDP with select-options parameters can be done in two Steps:

1.create a class in eclipse using ADT tool and define the interface as IF_AMDP_MARKER_HDB. This interface provides special power to the class which we can use SQL script code in the implementation of a Class. In the method implementation use the Apply Filter function on result dataset. Apply Filter function takes two arguments one is string parameters and other parameter is result dataset.

2.Create an ABAP program in ADT Tool and use the new syntax value operator to convert the select options of AMDP into a string. Use the class CL_SHDB_SELTAB=>COMBINE_SELTABS. The method COMBINE_SELTABS takes two parameters one is name and other parameter is DREF. Fill the method parameters and pass the value while calling the AMDP method in the ABAP program. when the AMDP is called then it creates a procedure at HANA database inside the schema which is mapped to ABAP.

now I will show the steps to create AMDP and calling the AMDP in more practical way:

Here we are taking VBAK and kna1 tables and displaying customer sale order for a particular country using AMDP .

create the structure and table type in se11 for the above scenario and use this structure in AMDP class.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
ABAP structure

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
Creating a class

click on finish and create the class definition and implementation with the interface and using apply filter function for customer sale details shown as below.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
fetching the details of customer in implementation

Now save and activate the class and now create an ABAP program.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
creating ABAP program

click on next and give the name of program and click on finish as shown below.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career

Now pass the select option parameters inside the class CL_SHDB_SELTAB under the method COMBINE_SELTABS and handle the client as shown below and call the AMDP method and fill the importing and exporting parameters as shown below.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
calling AMDP

now save and active and execute the program and give input select options ranges country and sale order as shown below.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
giving input values

now we can see the output for country from India to us and sale order number from 1 to 31 ranges.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
output

now go to open perspective in eclipse and select Hana development.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
Hana perspective

click on open and connect to database and go to schema which is mapped to ABAP and go to procedure and click on filter option and give AMDP class and method name to check at the database.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
procedure gets created

double click on the procedure to see the procedure that created on Hana database when the AMDP is called.

ABAP Managed Database, SAP ABAP Exam Prep, SAP ABAP Tutorial and Materials, SAP ABAP Exam, SAP ABAP Preparation, SAP ABAP Career
procedure

Source: sap.com

No comments:

Post a Comment