<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dynamically accessing subclass attribute from within superclass method in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557561#M1753791</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ABAP pros,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to dynamically access attributes from within a superclass method. This works for all superclass attributes but not for the subclass attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Imaging the following:&lt;/P&gt;&lt;P&gt;In an abstract superclass I define protected attributes a and b. In a subclass, inheriting from this superclass, I define a third protected attribute c. Now I'd like to define a method in the superclass which should dynamicall fill a structure out of all accessible instance attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method somehow looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;METHOD to_structure.

&amp;nbsp; DATA:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_structure_description TYPE REF TO cl_abap_structdescr,
&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_structure_object TYPE REF TO data,
&amp;nbsp;&amp;nbsp;&amp;nbsp; lv_empty TYPE string.

&amp;nbsp; FIELD-SYMBOLS:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ls_component&amp;gt; TYPE abap_compdescr,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_value&amp;gt; TYPE any,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ls_structure&amp;gt; TYPE any,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_structure_component_value&amp;gt; TYPE any.
&lt;/P&gt;&lt;P&gt;&amp;nbsp; " &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;get_structure_description( )&lt;/SPAN&gt; is a self written method that returns a RTTI description object of the desired structure of attributes
&amp;nbsp; lref_structure_description = me-&amp;gt;get_structure_description( ).

&amp;nbsp; IF es_structure IS REQUESTED.

&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE DATA lref_structure_object TYPE HANDLE lref_structure_description.
&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN lref_structure_object-&amp;gt;* TO &amp;lt;ls_structure&amp;gt;.

&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOP AT lref_structure_description-&amp;gt;components ASSIGNING &amp;lt;ls_component&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNASSIGN &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN me-&amp;gt;(&amp;lt;ls_component&amp;gt;-name) TO &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_value&amp;gt; IS NOT ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN lv_empty TO &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_structure_component_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNASSIGN &amp;lt;lv_structure_component_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN COMPONENT &amp;lt;ls_component&amp;gt;-name OF STRUCTURE &amp;lt;ls_structure&amp;gt; TO &amp;lt;lv_structure_component_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_structure_component_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_structure_component_value&amp;gt; = &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.

&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDLOOP.

&amp;nbsp;&amp;nbsp;&amp;nbsp; es_structure = &amp;lt;ls_structure&amp;gt;.

&amp;nbsp; ENDIF.

ENDMETHOD.
&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies within the line "&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN me-&amp;gt;(&amp;lt;ls_component&amp;gt;-name) TO &amp;lt;lv_value&amp;gt;.&lt;/SPAN&gt;". This works for &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = a and &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = b but not for &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = c (the subclass attribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I call the method on an instance of the subclass. The debugger shows that "me" is an instance of the subclass and if I enter "me-&amp;gt;c" in the debugger I see the corresponding value. But &amp;lt;lv_value&amp;gt; just won't get assigned in this case. It also does not work if I specify the component name fully dynamic (test = 'me-&amp;gt;' &amp;amp;&amp;amp; &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt;. &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN (test) TO &amp;lt;lv_value&amp;gt;.) nor if I explicitly use an object reference of the subclass (lref_subclass ?= me. &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;lref_subclass&lt;/SPAN&gt;-&amp;gt;(&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt;) TO &amp;lt;lv_value&amp;gt;.&lt;/SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;It's a 7.31 SP3 system.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what may be wrong here or is this just not possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Jun 2013 10:09:36 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-06-24T10:09:36Z</dc:date>
    <item>
      <title>Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557561#M1753791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ABAP pros,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to dynamically access attributes from within a superclass method. This works for all superclass attributes but not for the subclass attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Imaging the following:&lt;/P&gt;&lt;P&gt;In an abstract superclass I define protected attributes a and b. In a subclass, inheriting from this superclass, I define a third protected attribute c. Now I'd like to define a method in the superclass which should dynamicall fill a structure out of all accessible instance attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method somehow looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;METHOD to_structure.

&amp;nbsp; DATA:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_structure_description TYPE REF TO cl_abap_structdescr,
&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_structure_object TYPE REF TO data,
&amp;nbsp;&amp;nbsp;&amp;nbsp; lv_empty TYPE string.

&amp;nbsp; FIELD-SYMBOLS:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ls_component&amp;gt; TYPE abap_compdescr,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_value&amp;gt; TYPE any,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ls_structure&amp;gt; TYPE any,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_structure_component_value&amp;gt; TYPE any.
&lt;/P&gt;&lt;P&gt;&amp;nbsp; " &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;get_structure_description( )&lt;/SPAN&gt; is a self written method that returns a RTTI description object of the desired structure of attributes
&amp;nbsp; lref_structure_description = me-&amp;gt;get_structure_description( ).

&amp;nbsp; IF es_structure IS REQUESTED.

&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE DATA lref_structure_object TYPE HANDLE lref_structure_description.
&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN lref_structure_object-&amp;gt;* TO &amp;lt;ls_structure&amp;gt;.

&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOP AT lref_structure_description-&amp;gt;components ASSIGNING &amp;lt;ls_component&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNASSIGN &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN me-&amp;gt;(&amp;lt;ls_component&amp;gt;-name) TO &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_value&amp;gt; IS NOT ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN lv_empty TO &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_structure_component_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UNASSIGN &amp;lt;lv_structure_component_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN COMPONENT &amp;lt;ls_component&amp;gt;-name OF STRUCTURE &amp;lt;ls_structure&amp;gt; TO &amp;lt;lv_structure_component_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_structure_component_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_structure_component_value&amp;gt; = &amp;lt;lv_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.

&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDLOOP.

&amp;nbsp;&amp;nbsp;&amp;nbsp; es_structure = &amp;lt;ls_structure&amp;gt;.

&amp;nbsp; ENDIF.

ENDMETHOD.
&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem lies within the line "&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN me-&amp;gt;(&amp;lt;ls_component&amp;gt;-name) TO &amp;lt;lv_value&amp;gt;.&lt;/SPAN&gt;". This works for &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = a and &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = b but not for &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt; = c (the subclass attribute).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I call the method on an instance of the subclass. The debugger shows that "me" is an instance of the subclass and if I enter "me-&amp;gt;c" in the debugger I see the corresponding value. But &amp;lt;lv_value&amp;gt; just won't get assigned in this case. It also does not work if I specify the component name fully dynamic (test = 'me-&amp;gt;' &amp;amp;&amp;amp; &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt;. &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN (test) TO &amp;lt;lv_value&amp;gt;.) nor if I explicitly use an object reference of the subclass (lref_subclass ?= me. &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;ASSIGN &lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;lref_subclass&lt;/SPAN&gt;-&amp;gt;(&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;&amp;lt;ls_component&amp;gt;-name&lt;/SPAN&gt;) TO &amp;lt;lv_value&amp;gt;.&lt;/SPAN&gt;).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"&gt;It's a 7.31 SP3 system.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas what may be wrong here or is this just not possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 10:09:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557561#M1753791</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-24T10:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557562#M1753792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christopher,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in my understanding of OO attributes and methods of subclasses are never visible in the superclass method. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 12:45:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557562#M1753792</guid>
      <dc:creator>UweFetzer_se38</dc:creator>
      <dc:date>2013-06-24T12:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557563#M1753793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can see where you are coming from. One would assume if value is being displayed in debug window then it can be assigned. Can't really explain what is wrong here but thing which I noticed is changing visibility of attribute C in subclass from protected to public all of sudden make it accessible though ASSIGN statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pawan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 13:48:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557563#M1753793</guid>
      <dc:creator>Pawan_Kesari</dc:creator>
      <dc:date>2013-06-24T13:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557564#M1753794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christopher,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Subclass attributes cannot be accessed in the Super class, why because the Subclass attributes are &lt;STRONG&gt;not&lt;/STRONG&gt; visible to Super Class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Thanks,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 14:12:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557564#M1753794</guid>
      <dc:creator>VijayaKrishnaG</dc:creator>
      <dc:date>2013-06-24T14:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557565#M1753795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pawan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the visibility really seems to be the problem. I thought, if I call the method of the superclass on an object of the subclass, the visibility wouldn't matter. When I change the visibility of the subclass attribute to "public" or add the superclass as a friend to the subclass definition it works seamlessly. Thank you for the pointer!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used the following two classes to test this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;class Z_CL_TEST_SUPER definition
&amp;nbsp; public
&amp;nbsp; abstract
&amp;nbsp; create public .

public section.

&amp;nbsp; methods CONSTRUCTOR
&amp;nbsp;&amp;nbsp;&amp;nbsp; importing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !IV_A type STRING
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !IV_B type STRING .
&amp;nbsp; methods GET_C
&amp;nbsp;&amp;nbsp;&amp;nbsp; returning
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value(RV_VALUE) type STRING .
protected section.

&amp;nbsp; data ATTR_SUP_A type STRING .
&amp;nbsp; data ATTR_SUP_B type STRING .
private section.
ENDCLASS.


CLASS Z_CL_TEST_SUPER IMPLEMENTATION.

METHOD constructor.

&amp;nbsp; me-&amp;gt;attr_sup_a = iv_a.
&amp;nbsp; me-&amp;gt;attr_sup_b = iv_b.

ENDMETHOD.

METHOD get_c.

&amp;nbsp; DATA:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_subclass TYPE REF TO z_cl_test_sub,
&amp;nbsp;&amp;nbsp;&amp;nbsp; lv_attribute_name TYPE string.

&amp;nbsp; FIELD-SYMBOLS:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;lv_attribute_value&amp;gt; TYPE string.

&amp;nbsp; lv_attribute_name = 'attr_sub_c'.

&amp;nbsp; TRY.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lref_subclass ?= me.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ASSIGN me-&amp;gt;(lv_attribute_name) TO &amp;lt;lv_attribute_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF &amp;lt;lv_attribute_value&amp;gt; IS ASSIGNED.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rv_value = &amp;lt;lv_attribute_value&amp;gt;.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ENDIF.
&amp;nbsp;&amp;nbsp;&amp;nbsp; CATCH cx_root.
&amp;nbsp; ENDTRY.

ENDMETHOD.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;class Z_CL_TEST_SUB definition
&amp;nbsp; public
&amp;nbsp; inheriting from Z_CL_TEST_SUPER
&amp;nbsp; create public

&amp;nbsp; global friends Z_CL_TEST_SUPER .

public section.

&amp;nbsp; methods CONSTRUCTOR
&amp;nbsp;&amp;nbsp;&amp;nbsp; importing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !IV_A type STRING
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !IV_B type STRING
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; !IV_C type STRING .
protected section.

&amp;nbsp; data ATTR_SUB_C type STRING .
private section.
ENDCLASS.


CLASS Z_CL_TEST_SUB IMPLEMENTATION.

METHOD constructor.

&amp;nbsp; super-&amp;gt;constructor(
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv_a = iv_a
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv_b = iv_b
&amp;nbsp; ).

&amp;nbsp; me-&amp;gt;attr_sub_c = iv_c.

ENDMETHOD.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
&amp;nbsp; lref_subclass TYPE REF TO z_cl_test_sub,
&amp;nbsp; lv_c TYPE string.

CREATE OBJECT lref_subclass
&amp;nbsp; EXPORTING
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv_a = 'A'
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv_b = 'B'
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv_c = 'C'.

lv_c = lref_subclass-&amp;gt;get_c( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When removing the friends statement, get_c won't return the value anymore.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Christopher&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Christopher Fenn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 14:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557565#M1753795</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-24T14:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557566#M1753796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you'll just have to override the superclass method in your subclass to do what you need it to do... You can still call the superclass method and add some extra logic after. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also believe that a superclass having any knowledge of its subclasses is not really proper use of inheritance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 14:47:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557566#M1753796</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-24T14:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557567#M1753797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that is what I was wondering about. If it wasn't possible, it would render dynamic programming quite useless in an OO context as you would have to redefine every method of the superclass that aims to work on subclass attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Christopher&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 15:11:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557567#M1753797</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-24T15:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557568#M1753798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Lucas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;redefining the superclass method, implementing the subclass specific code in it and calling the superclass method afterwards, sounds like a great idea. Thank you for the hint!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal was to make the "framework" easily extensible by adding new subclasses to it. So I focused on implementing as much as possible in the abstract superclass (like persistency, serialisation, ...). The superclass methods are very generic through heavy usage of RTTI / RTTC classes. They have no special knowledge of the subclasses using it. The subclasses, on the other hand, have to follow some naming / visibility conventions to work as desired. The sample code I posted is greatly simplified to illustrate the problem I had.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Christopher&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Jun 2013 07:00:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557568#M1753798</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-25T07:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557569#M1753799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I just stumbled upon this poroblem as well. &lt;A href="http://help.sap.com/abapdocu_740/en/abapassign_mem_area_dynamic_access.htm" title="http://help.sap.com/abapdocu_740/en/abapassign_mem_area_dynamic_access.htm"&gt;ABAP Keyword Documentation&lt;/A&gt; states that this &lt;EM&gt;"may be used for all visible attributes of objects." &lt;/EM&gt;Since attributes of a subclass are not visible to the superclass, it won't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or should it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mean, the sublass inherits the method, making it its own method. At design time, it is pretty clear that this method belongs to the super class. At runtime, it belongs to the instance, which is an instance of the sub class. I guess one could argue whether visibility should be determined by where the method is implemented or by wht type of an instance the method belongs to at runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding would prefer the latter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 14:51:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557569#M1753799</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-03-05T14:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically accessing subclass attribute from within superclass method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557570#M1753800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is on purpose by SAP, this is kinda ridiculous. The super class is becoming part of the sub class, and the methods should behave exactly the same, with the same code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should work in either context, because &lt;EM&gt;me&lt;/EM&gt; is of the same type, and should have the same visibility, no matter where it was declared:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;ASSIGN &lt;/SPAN&gt;me&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;(attr_name&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;&amp;lt;data&amp;gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my perspective this clearly is a bug in ABAP. But as always SAP is probably going to ignore this, or simply say it is on purpose, because [fill in excuse of the day].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Feb 2016 10:05:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamically-accessing-subclass-attribute-from-within-superclass-method/m-p/9557570#M1753800</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-02-16T10:05:11Z</dc:date>
    </item>
  </channel>
</rss>

