{"id":1362,"date":"2015-03-24T13:23:04","date_gmt":"2015-03-24T12:23:04","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=1362"},"modified":"2015-03-24T13:23:04","modified_gmt":"2015-03-24T12:23:04","slug":"abap-list-interfaces-implemented-by-an-abap-class","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=1362","title":{"rendered":"ABAP &#8211; List interfaces implemented by an ABAP Class"},"content":{"rendered":"<p>This short code snippet shows how to a) get list of all interfaces implemented by given class, b) check if an interface is implemented by a class, c) list all direct implementations of given interface.<!--more--><\/p>\n<h2>List of interfaces implemented by a class<\/h2>\n<pre lang=\"abap\">DATA:\r\n  lo_class_description TYPE REF TO cl_abap_classdescr.\r\nCONSTANTS:\r\n  lc_class_name TYPE seoclsname VALUE 'CL_ABAP_CLASSDESCR'.\r\nFIELD-SYMBOLS:\r\n  &lt;ls_interface&gt; TYPE abap_intfdescr.\r\n\r\nlo_class_description ?= cl_abap_classdescr=&gt;describe_by_name( lc_class_name ).\r\n\r\nLOOP AT lo_class_description-&gt;interfaces ASSIGNING &lt;ls_interface&gt;.\r\n  WRITE:\/ &lt;ls_interface&gt;-name.\r\nENDLOOP.<\/pre>\n<h2>Does a class implement given interface?<\/h2>\n<pre lang=\"abap\">DATA:\r\n  lo_intf_description TYPE REF TO cl_abap_intfdescr.\r\nCONSTANTS:\r\n  lc_intf_name TYPE seoclsname VALUE 'IF_T100_MESSAGE',\r\n  lc_class_name TYPE seoclsname VALUE 'CX_CDC_RECORDER'.\r\n\r\nlo_intf_description ?= cl_abap_intfdescr=&gt;describe_by_name( lc_intf_name ).\r\n\r\nIF lo_intf_description-&gt;applies_to_class( lc_class_name ) = abap_true.\r\n  WRITE: 'Class ', \r\n         lc_class_name, \r\n         ' implements the following interface: ', \r\n         lc_intf_name.\r\nELSE.\r\n  WRITE: 'Class ', \r\n         lc_class_name, \r\n         ' does NOT implement the following interface: ', \r\n         lc_intf_name.\r\nENDIF.<\/pre>\n<h2>All direct implementations of an interface<\/h2>\n<pre lang=\"abap\">DATA:\r\n  lt_implementations TYPE seor_implementing_keys.\r\nCONSTANTS:\r\n  lc_intf_name TYPE seoclskey VALUE 'IF_T100_MESSAGE'.\r\n\r\n\r\nCALL FUNCTION 'SEO_INTERFACE_IMPLEM_GET_ALL'\r\n  EXPORTING\r\n    intkey       = lc_intf_name\r\n  IMPORTING\r\n    impkeys      = lt_implementations\r\n  EXCEPTIONS\r\n    not_existing = 1\r\n    OTHERS       = 2.\r\n\r\nCHECK sy-subrc = 0.\r\n\r\nLOOP AT lt_implementations ASSIGNING FIELD-SYMBOL(&lt;ls_implementation&gt;).\r\n  WRITE:\/ &lt;ls_implementation&gt;-clsname.\r\nENDLOOP.<\/pre>\n<p>For further details to get PARENT-CHILD links between classes\/interfaces, you can see the contents of the function module SEO_INTERFACE_IMPLEM_GET_ALL which reads data in form of <em>CLASS<\/em> &#8211; <em>REFCLASS<\/em> from table <em>VSEOIMPLEM.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This short code snippet shows how to a) get list of all interfaces implemented by given class, b) check if an interface is implemented by a class, c) list all direct implementations of given interface.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"ABAP - List interfaces implemented by an ABAP Class","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[16,9],"tags":[],"class_list":["post-1362","post","type-post","status-publish","format-standard","hentry","category-abap","category-development"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-lY","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1362"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1362\/revisions"}],"predecessor-version":[{"id":1363,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/1362\/revisions\/1363"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}