‎2007 Jun 05 2:46 PM
Hello!
Is it possible to get meta data about current method being executed? For example:
CLASS lcl_some_class IMPLEMENTATION.
METHOD some_method.
DATA: l_method_name TYPE char50.
* (do something to get method name)
WRITE 'Current method is: ', l_method_name.
ENDMETHOD.
ENDCLASS.And the result would be something like:
LCL_SOME_CLASS->SOME_METHODThanks!
Regards,
Igor
‎2007 Jun 05 2:55 PM
Hi Igor, this may not be fool proof, but it does work in my case.
report zrich_0003 .
*---------------------------------------------------------------------*
* CLASS lcl_some_class DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_some_class definition.
public section.
class-methods: some_method.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_some_class IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_some_class implementation.
method some_method.
data: l_method_name type char50.
data: icallstack type sys_callst.
data: xcallstack like line of icallstack.
call function 'SYSTEM_CALLSTACK'
importing
et_callstack = icallstack.
read table icallstack into xcallstack index 1.
if sy-subrc = 0 and xcallstack-eventtype = 'METH'.
l_method_name = xcallstack-eventname.
endif.
* (do something to get method name)
write:/ 'Current method is: ', l_method_name.
endmethod.
endclass.
start-of-selection.
call method lcl_some_class=>some_method.
Regards,
Rich Heilman
‎2007 Jun 05 2:55 PM
Hi Igor, this may not be fool proof, but it does work in my case.
report zrich_0003 .
*---------------------------------------------------------------------*
* CLASS lcl_some_class DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_some_class definition.
public section.
class-methods: some_method.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_some_class IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_some_class implementation.
method some_method.
data: l_method_name type char50.
data: icallstack type sys_callst.
data: xcallstack like line of icallstack.
call function 'SYSTEM_CALLSTACK'
importing
et_callstack = icallstack.
read table icallstack into xcallstack index 1.
if sy-subrc = 0 and xcallstack-eventtype = 'METH'.
l_method_name = xcallstack-eventname.
endif.
* (do something to get method name)
write:/ 'Current method is: ', l_method_name.
endmethod.
endclass.
start-of-selection.
call method lcl_some_class=>some_method.
Regards,
Rich Heilman
‎2007 Jun 05 3:17 PM
Thanks, Rich!
Good enough for me. I can get the class name using RTTI, so I guess I have it all.
Regards,
Igor