Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: [ABAP-OO] How to create dynamically a Method for a class?

$
0
0

Hi Rachid,

you can create a method dynamically, so it means, you have to know if this method has parameters, or not, if this method exist, or not, otherwise, you will get dump.

 

 

DATA:
        lo_object     
TYPE REF TO object,
        lv_method     
TYPE string,
        lv_classname  
TYPE seoclsname.

   lv_classname
= 'ZIBO_CL_TEST'.
   lv_method
= 'DYNAMIC_METHOD'.

     
CREATE OBJECT lo_object TYPE (lv_classname).
     
IF lo_object IS NOT INITIAL.
        lv_method
=  lv_method.
       
TRY.
           
CALL METHOD lo_object->(lv_method).

         
CATCH cx_sy_dyn_call_error .
        ENDTRY.

       
CLEAR lv_method.
     
ENDIF.


Regards

Ibr


Viewing all articles
Browse latest Browse all 8950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>