Skip to Content
author's profile photo Former Member
Former Member

Using RTTI to identify subclasses

Hello, here is my dilemma:

Class B inherits from Class A. Classes C and D inherit from Class B.

I need to test if object O is an instance of Class A or any of its subclasses (ie Class A, B, C or D). Using the method GET_RELATIVE_NAME is not suitable because then I must know the actual name of the subclass, which I will not. The methods APPLIES_TO and APPLIES_TO_CLASS do not seem to account for inheritance (ie Class D APPLIES_TO Class A is false, even though Class A is a superclass of Class D).

Any feedback would be very nice. I'd like to accomplish this, if possible, using RTTI since it is more elegant than simply casting the object into a reference of type Class A and seeing if an error is thrown.

I'm on 4.7, WebAS 6.30.

Cheers,

Mike

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2005 at 03:33 PM

    I know this is NOT a RTTI way of doing this task and I can tell you from looking for hours at RTTI that it does not look at the information in this "bottom-up" manner. Although, this would be totally unsupported you can recursivley read the VSEOEXTEND table. That table keeps the relations of all classes and sub-classes. Sadly, CL_ABAP_CLASSDESCR is marked as final so you can't even subclass it to add this functionality.

    hope this helps.

    -d

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.