Skip to Content
0
Former Member
Jul 01, 2016 at 01:08 PM

Get class name without object initialization

465 Views

Hi folks,

I'm using RTTS to dynamically get class name for an initialized object. Following codes work just fine:

data obj type ref to zflh_test_class
obj = new #( ).

data cls_descr type ref to cl_abap_classdescr.
cls_descr ?= cl_abap_classdescr=>describe_by_object_ref( obj ).
data(rel_name) = cls_descr->get_relative_name( ). " returns zflh_test_class

The question is: How can I get the class name without object initialization. I would like to have something like this

data obj type ref to zflh_test_class

data cls_descr type ref to cl_abap_classdescr.
cls_descr ?= cl_abap_classdescr=>describe_by_object_ref( obj ).
data(rel_name) = cls_descr->get_relative_name( ).

Of course cl_abap_classdescr=>describe_by_object_ref throws exception because "obj" is initial.

Any idea?

Cheers,

Ferry