2014 Dec 02 8:58 AM
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
2014 Dec 02 11:43 AM
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
2014 Dec 02 11:43 AM
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
2014 Dec 02 12:52 PM
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
2014 Dec 02 1:17 PM
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 ?
2014 Dec 02 1:23 PM
Take a look at view VSEOIMPLEM. There is the reference between classes and implemented interfaces.
Regards,
Ulrich
2014 Dec 02 1:40 PM
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
2014 Dec 02 2:27 PM
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
2014 Dec 02 2:29 PM
2014 Dec 02 2:30 PM
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.
2014 Dec 02 2:32 PM