Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Runtime type information

former_member192854
Active Participant
0 Kudos
749

Hi all,

is there a possibility within runtime type information to see which classes are using a certain interface from the CL_ABAP_INTFDESCR class? Or another OO way?

A selection on dbtab SEOMETAREL just doesn't seem the right way...

Best,

Sander

1 ACCEPTED SOLUTION
Read only

former_member201285
Active Participant
0 Kudos
704

Does "using" mean "implementing" in this context? Here is a sample code checking if a class implements a certain interface:

DATA: gr_descriptor TYPE REF TO cl_abap_objectdescr.        " RTTI

   

gr_descriptor ?= cl_abap_typedescr=>describe_by_name( 'ZIF_MY_INTERFACE' ).

   IF gr_descriptor->applies_to_class( 'MY_CLASS') = abap_true.

*  class implements the interface

   ENDIF.


Regards,

Ulrich


9 REPLIES 9
Read only

former_member201285
Active Participant
0 Kudos
705

Does "using" mean "implementing" in this context? Here is a sample code checking if a class implements a certain interface:

DATA: gr_descriptor TYPE REF TO cl_abap_objectdescr.        " RTTI

   

gr_descriptor ?= cl_abap_typedescr=>describe_by_name( 'ZIF_MY_INTERFACE' ).

   IF gr_descriptor->applies_to_class( 'MY_CLASS') = abap_true.

*  class implements the interface

   ENDIF.


Regards,

Ulrich


Read only

0 Kudos
704

Hi Ulrich,

actually I try to find classes which are using ZIF_MY_INTERFACE without knowing the class names / instances upfront.

Any ideas about that?

Thanks and best,

Sander

Read only

0 Kudos
704

I would guess that a where used in SE24 would do the trick. I just tried for interface IF_IXML_NODE and it works. Did you try it ?

Read only

0 Kudos
704

Take a look at view VSEOIMPLEM. There is the reference between classes and implemented interfaces.

Regards,

Ulrich

Read only

0 Kudos
704

Or use class CL_OO_IF_RELATIONS

You will find the implementing classes in attribute IMPLEMENTING_CLASSES after creating an instance. Pass the name of the interface to the constructor.

Regards,

Ulrich

Read only

0 Kudos
704

I'd think this has not much to do with the (runtime) type system.

Upon debuggng SE80 (when displaying an interface on the left) I found that function module SEO_INTERFACE_IMPLEM_GET_ALL is what SAP uses internally to find implementing classes.

As hinted, this function module uses DB view VSEOIMPLEM.

Cheers, Fred

Read only

0 Kudos
704

Based on the dbtab I mentioned, but good enough, thanks!

Read only

0 Kudos
704

Sure, but I actually wanted to have a code based solution.

Making a factory class which should execute some methods from some classes with a specific interface in them.

Read only

0 Kudos
704

Thanks Fred