Tuesday, 27 December 2016

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

With ABAP 7.4 SP08, the modification-free enhancement of AMDPs is now possible using so-called AMDP BAdIs. The AMDP BAdIs transmit the effect of the switches from the Switch Framework to the implementation of database procedures in the current database. It allows the definition of a clear contract between extension provider and extension consumer (aka implementer) through a dedicated interface. AMDP BAdIs are created in Enhancement Spots in the transaction SE20 and are later called within an AMDP implementation similarly to other AMDPs.
Tasks to be performed for modification-free extension of AMDP using BADI;

Extension Provider: Solution provider
  1. Create Enhancement Spot ( i.e. AMDP BADI Definition)
  2. Define AMDP BADI Interface and implement fallback Class.
  3. Integrate the enhancement spot in the application code.
Extension consumer: Customer
  1. Provide an implementation class for the AMDP BADI.
  2. Create a BADI implementation and set it to active.
  3. Test
We will follow the below steps to extend this AMDP method using BADI;

During the creation of a AMDP BAdI definition in SE20;
  1. New option “AMDP BAdI” must be checked
  2. Filters are not supported
  3. BAdI Interface must only contain AMDP method definition (check the prerequisites of method interfaces for AMDP methods)
  4. Fallback class must be specified
  5. Only AMDP classes can be provided as fallback class or implementation class
Regarding the implementation of BAdI classes (i.e. Fallback class or  implementation classes)
  1. Only AMDP implementations of the BAdI interface methods must be provided
  2. Only AMDP methods for a database platform can be implemented in a BAdI class  (only SAP HANA currently supported)
Regarding the invocation of a BAdI within an AMDP method
  1. BAdI invocation has to be declared after the addition USING of the relevant AMDP method. USING BADI_NAME=>METHOD_NAME
  2. The call is syntactically similar to a procedure call CALL “BADI_NAME=>METHOD_NAME”( * set input and output parameters here  );
We will take an example to show the customer classification demo report where it gives the category details for the customers.

Example customer classification Report and it will show the customer details along with category details:

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Example output of the customer classification results before modification AMDP method;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Example output of the customer classification results After modification AMDP method;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

 We will take a look at the class: ZCL_OAI_BUPA_CLASIFICATION;

In the below class implementation we can see AMDP method:EXICUTE.

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

The below tasks need to be performed to extend ABAP managed Database procedure using AMDP BADI’s.

1.Create Enhancement Spot using SE20 Transaction code ( i.e. AMDP BADI Definition)

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

2.Create BADI Definition for the Enhance spot.

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Here we have to select AMDP BADI checkbox.

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

3.Create Interface for that BADI;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Once interface created , we could see the below one;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s
Here we need to copy the existing interface definations into the new one and copy the AMDP method with rename to classify to enhance the existing logic.

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Fallback class must be specified;Only AMDP classes can be provided as fallback class or implementation class;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Call Fallback implantation class;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Call  the BADI from AMDP Method : EXICUTE from the class : ZCL_OAI_BUPA_CLASSIFICATION;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

We can enhance the logic in the implemented class : ZCL_OAI_CLASSIFICATION_IMPL01.

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

execute the Report and see the results after modification;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

Final results of category results after modification of AMDP method using BADI;

How to extend an ABAP Managed Database Procedures using AMDP BADI’s

No comments:

Post a Comment