cancel
Showing results for 
Search instead for 
Did you mean: 

Different runtime errors are coming on AMDP example

kngupta141
Participant
0 Kudos

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.

pfefferf
Active Contributor
0 Kudos

Can you please add a try/catch in your ABAP code to catch the exception. In the exception object you can check further details (like an error code and message) to get some further hints regarding the error. Can you please add the information what NetWeaver Version + DB version you are using and how the structure of table zmat_det_001 looks like.

kngupta141
Participant
0 Kudos

Hi Florian,

The error is not happening at select it is happening at the below line that is what surprises me.

METHOD fetch_matnr_data
  BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING zmat_det_001

I think we cannot catch exception here, please correct me if i am wrong. ZMAT_DET_001 is a CDS view just want to let you know.

Thanks and regards,

Gupta


kngupta141
Participant
0 Kudos

I hope this what you are looking

Sandra_Rossi
Active Contributor

Nagaraja Gupta Kadimesetty It surprises you, but it doesn't cost you a lot to just try !

BTW you shouldn't use generic types for the AMDP method parameters : "The typing of the parameters cannot be generic" i.e. declare TYPES tt_material TYPE STANDARD TABLE OF ty_material WITH EMPTY KEY, instead of the generic TYPE TABLE OF ty_material.

kngupta141
Participant
0 Kudos

Hi Sandra,

No, this does not solved my issue. I still see the same issue.

Regards,

Gupta

Sandra_Rossi
Active Contributor

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

kngupta141
Participant
0 Kudos

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

Sandra_Rossi
Active Contributor

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.

Accepted Solutions (1)

Accepted Solutions (1)

kngupta141
Participant

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.
Sandra_Rossi
Active Contributor

Getting the result you want and answering the question are 2 different things. So, I understand that you still don't have any explanation why you got the CX_AMDP_... exceptions?

Sandra_Rossi
Active Contributor

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

Answers (3)

Answers (3)

former_member302041
Contributor

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;
kngupta141
Participant
0 Kudos

Hi Andrey,

My cursor is not reaching to my select when i look in debug mode, it dumps well ahead.

Thanks and regards,

Gupta

former_member302041
Contributor
0 Kudos

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...

kngupta141
Participant
0 Kudos

I tried this option it didn't work

DoanManhQuynh
Active Contributor
0 Kudos

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.
kngupta141
Participant
0 Kudos

I am still seeing the same issue after implementing the code as mentioned by Quynh Doan Manh

Here as my new code

Class

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.

    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 mandt, matnr, werks, lgort;
  ENDMETHOD.
ENDCLASS.

Calling Program

REPORT ztest_gupta.

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

I am sure this not relating issue with view because in debug mode my cursor not reaching to my select but juts pasting code of my view

@AbapCatalog.sqlViewName: 'ZMAT_DET_001'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Material details'
@ClientDependent: true
@AbapCatalog.buffering.status: #SWITCHED_OFF
define view ZCDS_MATERIAL_DETAIL as select from mara
association [1..*] to marc as marc
    on mara.matnr = marc.matnr 
association [1..*] to mard as mard
on mard.matnr = mara.matnr{
    mara.mandt as mandt,
    mara.matnr as matnr, // Make association public
    marc.werks as werks,
    mard.lgort as lgort
}

Can any one implement the above all code and see is this issue happening in your system as well. Sorry for troubling you. Just trying to find the issue. If any rectifies the above code and let me know if it works in your system and also please explain what is the mistake i have done.

Regards,

Gupta

DoanManhQuynh
Active Contributor
0 Kudos

Sorry Nagaraja Gupta Kadimesetty, i just provided sample code how to catch the exception, not to solve your question...i dont have system here so cant apply your code...btw, what is the detail of exception error, you can see there is method get_text.

Sandra_Rossi
Active Contributor
0 Kudos

I just implemented your code in a small system, I've got no issue, 50.000 rows are returned from several clients. ABAP 7.52 SP 0, SAP S/4HANA 1709, HANA 2.00.024.01.1523431117.