cancel
Showing results for 
Search instead for 
Did you mean: 

Using RTTI to identify subclasses

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member10945
Contributor
0 Kudos

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