12-08-2017 1:36 PM
Hi,
I would like to get the Classname from an UNinstanciated object.
METHOD constructor.
DATA obj TYPE REF TO zcl_c1h_zamiz_fil_dao.
DATA classname TYPE string.
classname = CLASS=>Method( obj ) .
ENDMETHOD.
The DEBUGGER mode provides this information:
Thank you very much.
Rachid.
12-08-2017 1:46 PM
To say it correctly, you want the static type of an initial reference variable (there is not such a thing as an uninstantiated object).
Use RTTI.
DATA(class_name) =
CAST cl_abap_refdescr(
cl_abap_typedescr=>describe_by_data( oref )
)->get_referenced_type(
)->absolute_name.
12-08-2017 1:46 PM
To say it correctly, you want the static type of an initial reference variable (there is not such a thing as an uninstantiated object).
Use RTTI.
DATA(class_name) =
CAST cl_abap_refdescr(
cl_abap_typedescr=>describe_by_data( oref )
)->get_referenced_type(
)->absolute_name.
12-08-2017 3:44 PM
absolute_name returns for instance \CLASS=<the global class> (+ possibly some more complex "paths" for local classes)
You may use get_relative_name( ) to get the name of the class without the prefix \CLASS=
12-08-2017 3:58 PM
But absolute names are better suited for dynamic type specifications.
12-08-2017 5:23 PM
You're right (always 🙂 ). Sometimes the name of the class only is needed for some logics. As we don't know the final goal of the OP.