With AS ABAP 7.4 SP08 various ABAP (for SAP HANA) features and improvements have been delivered (see here). This is also the case for ABAP Managed Database Procedures (AMDPs).  You can read the ABAP News for 7.40, SP08 – ABAP Managed Database Procedures (AMDP) by Horst Keller.

In the present blog, I would like to emphasize the modification-free enhancement of AMDP using special Business Add-Ins, so-called AMDP BAdIs.

 

One the main advantages of the so-called Top-Down approach is that as a developer you remain in your familiar ABAP environment, despite the fact that you may be writing HANA-specific code. This is exactly the case with AMDPs which allow embedding SQLScript code into special class methods (so-called  AMDP methods). Another important advantage is that proven and well-known ABAP capabilities and concepts can then be applied on such objects, e.g. the standard ABAP transport mechanism and the version management.

 

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.

 

Below is a short video tutorial showing how to achieve it and additional information on that topic.

 

General information about BAdIs:

A BAdI is an object-oriented enhancement option, which makes it the most sophisticated enhancement type. The main characteristic of a BAdI is that it provides a mechanism to change the functionality of a well-defined business function without making changes to the delivered source code. Future upgrades of the original business function can be applied without losing the customer-specific enhancements or the need to merge the changes. The two code lines (the original one and the customer-specific coding) are strictly separated but still integrated.
To note is that the BAdI technology is not limited to SAP applications. BAdI calls can be integrated in customer applications, which in turn can then be enhanced by other customer applications. (More info …)

 

Special information and restrictions to be taken into consideration when working with AMDP BAdIs:

 

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
           );

 

Hope this information helps you. For more information check the online ABAP Keyword documentation in the SAP Help Portal. Various information (guides, tutorial, videos) around the ABAP development for SAP HANA can be found here.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. Anati Paul

    Hi Carine, Thanks for sharing wonderful blog..I hv implemented the scenario and working as expected. Can you please explain why Fallback class must be specified in case of AMDP BADI?

    regards, Anati

    (0) 
    1. Jasmin Gruschke

      Hi Anati,
      this has a rather technical reason. SQLScript procedures cannot be empty (this results in a syntax error). Moreover, the call of an AMDP (respectively the corresponding DB procedure) inside another AMDP is only syntactically correct, if the called DB exists. For this reason, the AMDP runtime requires that the developer provides a fallback implementation (otherwise the framework would need to guess a good fallback ;-)).
      Cheers,
        Jasmin

      (0) 
      1. Horst Keller

        Jasmin is right, there is a technical reason, but it´s not the reason that a SQLScript procedure cannot be empty. Why? In order to have an implementation you have to have an implementation class first and the same question remains: why do I need a fallback class at all?

        The main scenario for AMDP BAdIs is calling switchable enhancement AMDP procedures from other AMDP procedures. The problem is: When you implement the calling procedure in SQLScript, the called procedure must be statically available on the DB already. Otherwise, the calling procedure cannot be syntactically correct. That is different from pure ABAP, where you can create calls of BAdI methods, even if they are not available yet. Therefore, you must deliver at least one fallback implementation from the beginning. Only then, calling AMDP procedures can be implemented independent from actual enhancements.

        If nobody can point out any better reason, that´s how the documentation will be enhanced for release 7.50 …

        Thanks Jasmin, for notifying me 😉

        (0) 
        1. Anati Paul

          thanks for sharing 🙂   this ..so fallback class imp. is must in AMDP BADI.

          can you also share some inside on why filter is not suported in case of AMDP  BADI? is there any change in release 7.50 to handle this filter part

          regards,Anati

          (0) 
          1. Horst Keller

            can you also share some inside on why filter is not suported in case of AMDP  BADI? is there any change in release 7.50 to handle this filter part

            The problem is, that with AMDP BAdI you have a mixed framework, involving ABAP and SQLScript, application server and database server.  In contrast to the ABAP only BAdI world, where everything can be done within one consistent layer, the introduction of filters to AMDP BAdI would be difficult from a technical point of view and the solution would not be too performant as well. Therefore, I’m sorry to say, do not expect filters for AMDP BAdIs in an upcoming release …

            Regards

            Horst

            (0) 

Leave a Reply