Skip to Content
-1

Different runtime errors are coming on AMDP example

Hi everyone,

I am trying to learn AMDP, so i have written a small code for execution i am seeing different runtime error on every execution. Can any one help me how to solve.

my class code:

CLASS zgtest_amdp DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .


  PUBLIC SECTION.
    INTERFACES: if_amdp_marker_hdb.
    TYPES: BEGIN OF ty_material,
             mandt TYPE mandt,
             matnr TYPE mara-matnr,
             werks TYPE marc-werks,
             lgort TYPE mard-lgort,
           END OF ty_material,


           tt_material TYPE TABLE OF ty_material.


    METHODS: fetch_matnr_data EXPORTING VALUE(et_material) TYPE tt_material.
 
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS zgtest_amdp IMPLEMENTATION.
  METHOD fetch_matnr_data
  BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zmat_det_001.

    et_material =  select *
     from zmat_det_001 ORDER BY matnr, werks, lgort;

  ENDMETHOD.

ENDCLASS.

my calling program code:

START-OF-SELECTION.
  DATA(lo_amdp) = NEW zgtest_amdp( ).
  lo_amdp->fetch_matnr_data( IMPORTING et_material = DATA(lt_data) ).

on entering fetch_matnr_data the program dumps.

Add comment
10|10000 characters needed characters exceeded

  • Nagaraja Gupta Kadimesetty I did a test and could catch the exception, the peculiarity being that the AMDP exception is wrapped into a CX_SY_NO_HANDLER this is the one to catch (or CX_ROOT). You'll get the details of the AMDP exception inside the attribute PREVIOUS.

    PS: I could check that my remark about generic types doesn't apply to your type (tt_material TYPE TABLE OF ty_material) which is complete (because, if nothing is explicitly mentioned, it's a standard table with non-unique key made of all first non-numeric components).

  • Hi Sandra,

    could you please post your code just to see the differences between my code and your code and also how you are catching the exception at method entry level.

    Regards,

    Gupta

  • Sure:

    DATA(lo_amdp)=NEW zgtest_amdp().
    TRY.
      lo_amdp->fetch_matnr_data(IMPORTING et_material =DATA(lt_data)).
    CATCH cx_root INTO DATA(lx).
      BREAK-POINT. " <== have a look at LX->PREVIOUS
    ENDTRY.
  • Follow
  • Get RSS Feed

4 Answers

  • Best Answer
    Feb 20 at 12:50 AM

    Issue is solved with the help of below link

    implement-and-consume-your-first-abap-managed-database-procedure-on-hana

    Here is my new code: Just adding client as a parameter solved my issue.

    Calling program

    START-OF-SELECTION.
      BREAK nkadimesetty.
      DATA(lo_amdp) = NEW zgtest_amdp( ).
    
      TRY.
          lo_amdp->fetch_matnr_data( EXPORTING ev_client = sy-mandt IMPORTING et_material = DATA(lt_data) ).
        CATCH cx_amdp_error INTO DATA(lo_amdp_error).
      ENDTRY.
    

    My new class code

    CLASS zgtest_amdp DEFINITION
      PUBLIC
      FINAL
      CREATE PUBLIC .
    
      PUBLIC SECTION.
        INTERFACES: if_amdp_marker_hdb.
        TYPES: BEGIN OF ty_material,
                 mandt TYPE mara-mandt,
                 matnr TYPE mara-matnr,
                 werks TYPE marc-werks,
                 lgort TYPE mard-lgort,
               END OF ty_material,
               tt_material TYPE STANDARD TABLE OF ty_material WITH EMPTY KEY.
        METHODS: fetch_matnr_data IMPORTING VALUE(ev_client)   TYPE sy-mandt
                                  EXPORTING VALUE(et_material) TYPE tt_material
         RAISING cx_amdp_error.
      PROTECTED SECTION.
      PRIVATE SECTION.
    ENDCLASS.
    
    CLASS zgtest_amdp IMPLEMENTATION.
      METHOD fetch_matnr_data
      BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zmat_det_001.
        et_material =
        select *
         from zmat_det_001
         WHERE mandt = ev_client
         ORDER BY mandt, matnr, werks, lgort;
      ENDMETHOD.
    ENDCLASS.
    
    Add comment
    10|10000 characters needed characters exceeded

    • After a little research in SAP notes, I see that you may get a short dump with the exception CX_AMDP_EXECUTION_FAILED (event if it's caught in the ABAP code). Maybe there are some SAP notes or kernel which could be applied in your system.

      In short, I understand that the cause of your short dumps is the HUGE volume of data returned.

      Your solution is to reduce the volume of data returned so that it can be contained in the memory (even with the "client" selection, the volume could be above the memory limits) - anyway, although I'm a beginner in AMDP, I think that such SELECTs don't make sense to be executed via AMDP, but should be executed via ABAP SQL (SELECT ... PACKAGE SIZE ... for instance).

      All answers were misled, because it seemed obvious that a "CX" exception could be caught but you were in a rare case of a "bug/memory limits reached (anything can happen)".

      About CX_AMDP_VERSION_MISMATCH, the only reason I could find is that your system has coverage activated, which is solved by a new kernel -> 2091913 - Repeated runtime error AMDP_VERSION_MISMATCH in systems with Coverage Analyzer. I also saw that in exceptional cases there could be some desynchronizations, you may run the program RSDBGEN_AMDP for the given AMDP class with option "Delete database objects" to force the regeneration of the corresponding database procedure(s).

  • Feb 17 at 07:58 AM

    Is your "select * ..." statement returns the same as type you defined?

    Did you try to write like this:

    et_material =  select namdt, matnr, werks, lgort
         from zmat_det_001 ORDER BY matnr, werks, lgort;
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 18 at 01:00 AM

    you should add CX_AMDP_ERROR as exception parameter of method fetch_matnr_data, when you call that method wrap it in try..catch to get more detail of error, below is one of examples from SAP:

        DATA: iref TYPE REF TO if_demo_amdp_interface,
              cref TYPE REF TO cl_demo_amdp_superclass.
        CASE cl_db_sys=>is_in_memory_db.
          WHEN abap_true.
            cref = NEW cl_demo_amdp_subclass_hdb( ).
            iref = NEW cl_demo_amdp_implement_hdb( ).
          WHEN abap_false.
            cref = NEW cl_demo_amdp_subclass_open( ).
            iref = NEW cl_demo_amdp_implement_open( ).
        ENDCASE.
        TRY.
            iref->get_scarr( EXPORTING clnt     = sy-mandt
                             IMPORTING carriers = DATA(result1) ).
            cref->get_scarr( EXPORTING clnt     = sy-mandt
                             IMPORTING carriers = DATA(result2) ).
          CATCH cx_amdp_error INTO DATA(amdp_error).
            cl_demo_output=>display( amdp_error->get_text( ) ).
            RETURN.
        ENDTRY.
    
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 18 at 10:27 AM

    try to run the report in se38 RSDBGEN_AMDP.

    Select your class and then select "Delete Database Object" and run.

    Then execute your program "ztest_gupta" - AMDP database object should be regenerated...

    Add comment
    10|10000 characters needed characters exceeded