Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

working with class based exception and dynamic method calls

udobuchter
Discoverer
0 Likes
2,950

Hi Gurus,

we just changed out ERP from EHP6 to EHP7.

Since we did so we are facing an issue with an Z-Report we are using quite often.

This reports looks up Workitems and executes the according methods so that we can go into debugging if we were facing any problems or errors.

since the EHP Upgrade this statement has problems:


  data:        lt_parmbind   type abap_parmbind_tab,

        lt_excpbind   type abap_excpbind_tab,

        lo_runtime    type ref to object.

    call method lo_runtime->(iv_cls_method)

      parameter-table

      lt_parmbind

      exception-table

      lt_excpbind.

this CALL METHOD Statement has Problem with the Exception Table. We are quite often getting DYN_CALL_METH_EXCP_NOT_FOUND short dumps with Exception "CX_SY_DYN_CALL_EXCP_NOT_FOUND".

The system has problems handling the content of lt_excpbind. if i clear this table the CALL METHOD statement works fine.

AS an example we are trying to call /IDXGC/CL_PD_PROCESS_STEPS-->CREATE_DATA. This method has 2 exceptions

/IDXGC/CX_PROCESS_ERRORProcess Layer Exception
CX_BO_TEMPORARYTemporary Business Exception

The Content of LT_EXCPBIND is

INDEXNAMEVALUE
2/IDXGC/CX_PROCESS_ERROR1
2CX_BO_TEMPORARY2

From my point of view the Problem ist, that they are marked as "class based". I think so because if you looked up the SAP Help for the EXCEPTION-TABLE Statement it is written that is statement only works for none-classbased exception.

I think that restriction is quiet clear. But what i am wondering about is.. that restriction also exists for EHP6. And in EHP6 it work. Does anyone know why? Or how i can change me CALL METHOD Statement that i will work again?

Best Regards

Udo

1 ACCEPTED SOLUTION
Read only

Former Member
1,567

Hi Udo,

the exception-table must contain only non-class-based exceptions. If you want call a dynamic method with class-based exceptions you dont fill the exception-table. You have to call the dynamic-method with TRY...CATCH...ENDTRY. If you dont know exactly which exception this method can raise you can catch CX_ROOT, the mother of all exception classes.

Excample:

TRY.

  CALL METHOD lr_instance->(method_name)

     PARAMETER-TABLE ptab.

CATCH cx_root into lr_error.

   lv_error = lr_error->get_text( ). "--> maybe a usefull error message

ENDTRY.

Greetz, Matthias

2 REPLIES 2
Read only

Former Member
1,568

Hi Udo,

the exception-table must contain only non-class-based exceptions. If you want call a dynamic method with class-based exceptions you dont fill the exception-table. You have to call the dynamic-method with TRY...CATCH...ENDTRY. If you dont know exactly which exception this method can raise you can catch CX_ROOT, the mother of all exception classes.

Excample:

TRY.

  CALL METHOD lr_instance->(method_name)

     PARAMETER-TABLE ptab.

CATCH cx_root into lr_error.

   lv_error = lr_error->get_text( ). "--> maybe a usefull error message

ENDTRY.

Greetz, Matthias

Read only

manwell77t
Explorer
0 Likes
1,567

Class-based exceptions must be caught using try/catch statement.

Calling dynamically a method catchable exceptions are:

CX_SY_DYN_CALL_EXCP_NOT_FOUND

CX_SY_DYN_CALL_ILLEGAL_CLASS 

CX_SY_DYN_CALL_ILLEGAL_METHOD

CX_SY_DYN_CALL_PARAM_MISSING 

CX_SY_DYN_CALL_PARAM_NOT_FOUND 

CX_SY_REF_IS_INITIAL

Anyway catching cx_root (as shown by Matthias) will catch everything is catchable.