‎2007 Apr 27 7:55 AM
Hi All,
I have an object and I want to know th name of the class to which the object belongs. Can some body help me on this.
Regards,
Jenish.
‎2007 Apr 27 1:19 PM
Hello Jenish
Since you need to know runtime information you should use the appropriate <b>RTTI </b>classes.
Either you use class <b>CL_ABAP_CLASSDESCR</b> or you could use the following sample coding:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_RUNTIME
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_runtime.
TYPE-POOLS: abap.
DATA:
gd_class TYPE abap_abstypename,
* go_classdescr type ref to cl_abap_classdescr,
go_docking TYPE REF TO cl_gui_docking_container.
START-OF-SELECTION.
CREATE OBJECT go_docking.
gd_class = cl_abap_classdescr=>get_class_name( go_docking ).
WRITE: / 'Class', gd_class.
END-OF-SELECTION.Regards
Uwe
‎2007 Apr 27 7:59 AM
Double click on the object's name in the abap editor, and you will the data declaration of the object :
data: l_object type ref to zcl_class.
ZCL_CLASS is the requested class.
regards,
Hans
Please reward all helpful answers !!!!!
‎2007 Apr 27 8:03 AM
I wand to get the class name at runtime. I have a variable which carries the reference of some object. From this object I want to find the name of the class to which the object refers.
‎2007 Apr 27 11:05 AM
Hi Jenish,
Please check the static public method CF_ISSR_BASI_OBJECT=>GET_CLASSNAME.
You need to pass the object instance to this method to get the class name.
Hope this helps.
Thanks,
Rashmi.
Message was edited by:
Rashmi Joshi
‎2007 Apr 27 1:19 PM
Hello Jenish
Since you need to know runtime information you should use the appropriate <b>RTTI </b>classes.
Either you use class <b>CL_ABAP_CLASSDESCR</b> or you could use the following sample coding:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_RUNTIME
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_runtime.
TYPE-POOLS: abap.
DATA:
gd_class TYPE abap_abstypename,
* go_classdescr type ref to cl_abap_classdescr,
go_docking TYPE REF TO cl_gui_docking_container.
START-OF-SELECTION.
CREATE OBJECT go_docking.
gd_class = cl_abap_classdescr=>get_class_name( go_docking ).
WRITE: / 'Class', gd_class.
END-OF-SELECTION.Regards
Uwe
‎2007 Apr 27 1:22 PM