Skip to Content
Author's profile photo Amol Samte

Handling Internal-table inside AMDP.

Hi All,

While developing AMDP class there must be a situation like how to handle internal table inside AMDP.

Well below is the example for that in short and sweet manner.

Before moving forward let’s see an overview of AMDP and other intresting stuff is


ABAP Managed Database Procedures – Introduction

Accessing tables from different schema through AMDP.

Call AMDP(ABAP Managed Database Procedure) Inside AMDP Method

Scenario :- 1.Suppose you have Airline code(Carrid) and connection number(Connid) in an internal table based on that you need to fetch data from inside AMDP.

Steps :

AMDP Definition :


AMDP Implementation :


Calling AMDP In Program :


Output :


Hope this will help,

Thanks & Regards,


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jasmin Gruschke
      Jasmin Gruschke

      Hi Amol,
      just a short comment to clarify for those new to AMDPs. In the SQLScript coding, so in the AMDP implementation, the objects it_sflight and et_flight_dtl are *not* internal tables. What technically happens, is that the AMDP runtime creates temporary tables for your tabular input/ouput parameters, which contain the data of the ABAP internal tables during runtime. This also means, that the data is copied from the ABAP layer to the DB layer and vice versa. This is something you have to keep in mind from a performance perspective. So my advice of precaution - when you use AMDPs for code pushdown and you use this pattern, keep also in mind that you don't do "data pushdown" by means of transferring a lot of data from internal tables to HANA and vice versa.

      Author's profile photo Amol Samte
      Amol Samte
      Blog Post Author

      Hi Jasmin,

      Its very good suggestion and explained in very good manner.



      Author's profile photo SeethaRamaiah Bharani
      SeethaRamaiah Bharani

      Hello Jasmin,

      Guten Tag!!!

      I have read document and have a little confusion.

      AMDP Method Code looks like a FAE functionality in ABAP. As you said as a precaution, transferring huge amount of ITAB data to HANA DB causes performance issue. In case if we want transfer the huge amount of the data  to achieve Code Push down, AMDP is not suitable?

      Thanks and Regards,


      Author's profile photo Oliver Sviszt
      Oliver Sviszt

      Hi Jasmin,


      I see you are an AMDP expert - maybe you have a hint for me, or a good connection to the development team 🙂


      With 7.52 you have the possibility to use ABAP macros in the source of the SQL procedure as described here. This is very good to save the redundant definition of types:

      METHOD demo_abap_types BY DATABASE PROCEDURE 
                             FOR HDB LANGUAGE SQLSCRIPT. 
        DECLARE mytab table( mandt  "$ABAP.type( mandt )", 
                             uname  "$ABAP.type( syst_uname )", 
                             langu  "$ABAP.type( syst_langu )", 
                             datum  "$ABAP.type( syst_datum )", 
                             text   "$ABAP.type( line-text )", 
                             number "$ABAP.type( f )" ); 

      What I would like to achieve is to declare a table type in ABAP (where you can have all the goodies like INCLUDE, automatic generation etc.), and have the corresponding table type created on SQL side by the AMDP framework, and finally reference that in SQL to set type of a 'local' variable in SQL. Sometimes this is required, because implicit typing is error prone.

      According to the SQL script reference you can do:

      DECLARE lt_variable <table_type>;

      The issue is just that there is no table type, because AMDP does not replicate any tables from ABAP to SQL except the ones used as the input/output parameters of the AMDP procedures. Creating the table type manually is then again manual work.

      Something like (attention - pseudocode!)

        DECLARE mytab "$ABAP.tabtype( z_my_class=>tt_my_table_type )"; 

      could really be a killer-beast 🙂

      Or, possibly a simpler solution - by annotating the table type itself for use in the database, sothing like (attention - pseudocode!)

                                                        PUBLISH TO DATABASE.


      Thank you,


      Author's profile photo Mynyna Chau
      Mynyna Chau

      Commenting on a blog post with the interest to receive answers to specific questions related to issues, is not a good idea. Instead, please ask your question in the SAP Community Q&A forum: Once you provide details to your question, it increases the chance that active community members tracking questions will help providing answers.


      Author's profile photo Marco Sposa
      Marco Sposa

      Hello Jasmin,

      thanks for the advise, what would be the best way to handle huge aumount of data. I guess pattern with select in the database would be even worst.


      Author's profile photo Jasmin Gruschke
      Jasmin Gruschke

      Hi Marco,

      as always "it depends" especially on the use case, hard to give a general advice ;-).


      Author's profile photo Marco Sposa
      Marco Sposa

      HI Jasmin,

      thanks for answering, i have around  600 K rows and i have to do a lot of calculation in an internal table!