‎2009 Apr 02 9:57 PM
Hi;
Is there any system variable like SY-REPID or CPROG which I can use inside a method to know the Class and the Method name?
SG.
‎2009 Apr 03 7:22 AM
Hello
Sample report ZUS_SDN_LOCAL_CALL_SYSTEMSTACK shows you how to solve your problem:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_LOCAL_CALL_SYSTEMSTACK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_local_call_systemstack.
*----------------------------------------------------------------------*
* CLASS lcl_myclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
method_one,
method_two,
get_system_stack
RETURNING value(rd_method) TYPE string.
ENDCLASS. "lcl_myclass DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_myclass IMPLEMENTATION
*----------------------------------------------------------------------*
* Thread: System Variable which stores Method name
* <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1294681"></a>
*----------------------------------------------------------------------*
CLASS lcl_myclass IMPLEMENTATION.
METHOD get_system_stack.
* define local data
DATA: ld_next TYPE i,
lt_callstack TYPE abap_callstack,
ls_call TYPE abap_callstack_line.
CALL FUNCTION 'SYSTEM_CALLSTACK'
EXPORTING
MAX_LEVEL = 2
IMPORTING
callstack = lt_callstack
* ET_CALLSTACK =
.
LOOP AT lt_callstack TRANSPORTING NO FIELDS
WHERE ( blocktype = 'METHOD'
AND blockname = 'GET_SYSTEM_STACK' ).
ld_next = syst-tabix + 1.
EXIT.
ENDLOOP.
READ TABLE lt_callstack INTO ls_call INDEX ld_next.
rd_method = ls_call-blockname.
ENDMETHOD. "get_system_stack
METHOD method_one.
DATA: ld_string TYPE string.
ld_string = lcl_myclass=>get_system_stack( ).
MESSAGE ld_string TYPE 'I'.
ENDMETHOD. "method_one
METHOD method_two.
DATA: ld_string TYPE string.
ld_string = lcl_myclass=>get_system_stack( ).
MESSAGE ld_string TYPE 'I'.
ENDMETHOD. "method_two
ENDCLASS. "lcl_myclass IMPLEMENTATION
START-OF-SELECTION.
BREAK-POINT.
lcl_myclass=>method_one( ).
lcl_myclass=>method_two( ).
Regards
Uwe
‎2009 Apr 03 7:22 AM
Hello
Sample report ZUS_SDN_LOCAL_CALL_SYSTEMSTACK shows you how to solve your problem:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_LOCAL_CALL_SYSTEMSTACK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_local_call_systemstack.
*----------------------------------------------------------------------*
* CLASS lcl_myclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_myclass DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
method_one,
method_two,
get_system_stack
RETURNING value(rd_method) TYPE string.
ENDCLASS. "lcl_myclass DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_myclass IMPLEMENTATION
*----------------------------------------------------------------------*
* Thread: System Variable which stores Method name
* <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1294681"></a>
*----------------------------------------------------------------------*
CLASS lcl_myclass IMPLEMENTATION.
METHOD get_system_stack.
* define local data
DATA: ld_next TYPE i,
lt_callstack TYPE abap_callstack,
ls_call TYPE abap_callstack_line.
CALL FUNCTION 'SYSTEM_CALLSTACK'
EXPORTING
MAX_LEVEL = 2
IMPORTING
callstack = lt_callstack
* ET_CALLSTACK =
.
LOOP AT lt_callstack TRANSPORTING NO FIELDS
WHERE ( blocktype = 'METHOD'
AND blockname = 'GET_SYSTEM_STACK' ).
ld_next = syst-tabix + 1.
EXIT.
ENDLOOP.
READ TABLE lt_callstack INTO ls_call INDEX ld_next.
rd_method = ls_call-blockname.
ENDMETHOD. "get_system_stack
METHOD method_one.
DATA: ld_string TYPE string.
ld_string = lcl_myclass=>get_system_stack( ).
MESSAGE ld_string TYPE 'I'.
ENDMETHOD. "method_one
METHOD method_two.
DATA: ld_string TYPE string.
ld_string = lcl_myclass=>get_system_stack( ).
MESSAGE ld_string TYPE 'I'.
ENDMETHOD. "method_two
ENDCLASS. "lcl_myclass IMPLEMENTATION
START-OF-SELECTION.
BREAK-POINT.
lcl_myclass=>method_one( ).
lcl_myclass=>method_two( ).
Regards
Uwe
‎2009 Apr 03 2:18 PM
Uwe:
Basically I wanted to check the method name inside a Class of a PROXY. The FM which you have used gives me all the details I need. Thanks a Lot!!
‎2009 Apr 03 2:18 PM
Uwe:
Basically I wanted to check the method name inside a Class of a PROXY. The FM which you have used gives me all the details I need. Thanks a Lot!!