‎2016 Mar 03 1:42 PM
hi!
is there a way to check an interface method is implemented? RTTS provide a table of all methods in CL_ABAP_OBJECTDESCR->METHODS, which has attributes like IS_INTERFACE or IS_REDEFINED. But nothing specific for interface methods like "IS_IMPLEMENTED" (what I would need).
Any suggestions welcome
Thanks,
Roland
‎2016 Mar 03 2:51 PM
Hi Roland,
Wouldn't it be sufficient to find out whether the class in question implements the interface containing this method in general? If such interface is listed in cl_aba_objectdescr->interfaces it should be guaranteed that it also implements the method because a class which binds itself to implement an interface cannot be activated unless it actually does implement all methods from that interface.
Best regards
Michal
‎2016 Mar 03 3:03 PM
Thanks Michal for your reply. In earlier versions your statement was true; but at least in the system I'm currently developing (7.40), not all interface-methods of an interface need to be implemented. In the interface definition, there is a way to tell the system what to do in case an implementation is missing but the method gets executed ("default fail" will throw an exception, the other option is to simulate empty method behavior).
‎2016 Mar 03 3:24 PM
I think you are referring to PARTIALLY IMPLEMENTED , but this is only valid for ABAP Unit Test class. It can't be used anywhere else.
See this discussion on Blog - ABAP News for Release 7.40 - ABAP Objects | SCN
Regards,
Naimesh Patel
‎2016 Mar 03 3:25 PM
I see Roland, I had no clue this was possible. Due to that this task becomes pretty tricky! I'd let you know if something came on my mind. Unfortunately for the time being I am out of ideas
‎2016 Mar 04 8:37 AM
If you know the methods from the interface and assuming it is a global class, try calling cl_oo_classname_service=>get_all_method_includes it will return the implemented methods
‎2024 Aug 19 11:26 PM
I know this question is quite old, but I had to find a way to do this in ABAP for Cloud Development.
cl_oo_classname_service is not released for use, so another approach was needed (calling the method with fake parameters is not an option).
The solution comes complements of the XCO classes. With these classes, you can read the source code of the method implementation into a string table. If the method is not implemented, an exception is raised. Here is an example:
TRY.
xco_cp_abap_repository=>object->clas->for( '<name of class>' )->implementation->method('<name of interface>~<name of method')->content( )->get_source( ).
" method is implemented
CATCH cx_xco_runtime_exception.
" method is not implemented
ENDTRY.