Skip to Content

How to invoke AMDP from BPC Script Logic BAdi

From NetWeaver 740, AMDP( ABAP Managed Database Procedures ) has been supported. With AMDP, developers can write database procedures directly in ABAP. Using AMDP allows developers to create and execute those database procedures in the ABAP environment using ABAP methods and ABAP data types.

Today I’m going to show you how to invoke AMDP from Script Logic in BPC standard model.

Firstly as a starting point, you need to create a normal Custom Logic BAdi. This can be done in transaction SE18. In this example, we created a BAdi named ZBPC_CALL_AMDP.

Then we need to create a class as the implementation of this BAdi. The class need to implement 3 interfaces:

  • IF_BADI_INTERFACE
  • IF_UJ_CUSTOM_LOGIC
  • IF_AMDP_MARKER_HDB

Notice that because this class contains AMDP, it has to be developed in the ABAP Development Tools. Below is the full content of the code. As this article is not showing you how to develop ADMP, I used a very simple dummy SQL in the method.

class ZCL_BPC_AMDP definition
  public
  final
  create public .

public section.

  interfaces IF_BADI_INTERFACE .
  interfaces IF_UJ_CUSTOM_LOGIC .
  interfaces IF_AMDP_MARKER_HDB .

  methods call_amdp.

protected section.
private section.
ENDCLASS.

CLASS ZCL_BPC_AMDP IMPLEMENTATION.

  method IF_UJ_CUSTOM_LOGIC~CLEANUP.
  endmethod.

  method IF_UJ_CUSTOM_LOGIC~EXECUTE.
  call method call_amdp.
  endmethod.

  method IF_UJ_CUSTOM_LOGIC~INIT.
  endmethod.

  method call_amdp by DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT options READ-ONLY.

  select * from dummy;

  ENDMETHOD.
ENDCLASS.

Last step for BAdi creation is the Filter, to be simple I used “AMDP”.

Now the BAdi creation is completed. Let’s try to create a Script to invoke it. As the BAdi created above doesn’t rely on any structure. You can create the script in any model. Below is the sample Script:

*START_BADI AMDP
QUERY=OFF
WRITE=OFF
*END_BADI

Now you can run the script in Data Manager or UJKT.

5 Comments
You must be Logged on to comment or reply to a post.
  • The only I’d change to let the parameter WRITE as ON, include a OUT parameter in the procedure type CT_DATA.

    The result of the procedure would be passed onto CT_DATA and then the standard write back will do its thing, therefore handling security, work status etc.

    • I have a couple of questions ( I will open a separate thread in SCN ) but here are my doubts

       

      1. Has any one actually made the AMDP BADI for BPC work . I am reading documentation that AMDP BADI does not support filters , but BPC BADI needs a filter defied so that it can be called in BPC

      2. Embededd BPC provided hooks like I_VIEW for input buffer and e_View as out buffer , how ever BPC standard provides CT_DATA which is of internal table type

       

      so how hows one read or assign back to CT_DATA..

       

      so in the above example , the author is reading from dummy , but in an actual exaple he would read from CT_DATA

       

      how would i read from ct_data inside my HDB method ,

      and how do I assign my result set to the ct_data

      • Sorry, but not clear – what is the issue? Instead of processing CT_DATA you can have empty CT_DATA with QUERY=OFF and read data from AMDP. Then you assign results to CT_DATA and it will be written.

  • Hi Sibo,

    When I create the BADI Implementation its not showing the Filter Values Option. I tried using both custom Interface and IF_UJ_CUSTOM_LOGIC for the Enhancement Spot.

    Am I missing something?

    Enhancement Spot:

    I tried checking the “Limited Filter Use” and created a Filter, I am getting an error “Filter conditions are not supported in AMDP BAdIs”. How did you make it work on your end? Is there any setting/flags I have to change as a work around?

     

    Thanks

    Abhi