Skip to Content
avatar image
-1
Former Member

How to get the CLASSNAME from an UNINSTANCIATED object.

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.

ybq7a.png (18.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 08, 2017 at 01: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.
    
    Add comment
    10|10000 characters needed characters exceeded