<?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 Re: Modify read-only static attribute from a class enhancement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011322#M1897293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Obviously that would be ideal, but the enhancement of classes isn't (as you've found) entirely straightforward - so some convoluted solution might be the only way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see a problem with creating a small class for one specific purpose. I've often done it. More often in Java, for sure, but also in ABAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Apr 2015 17:04:22 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2015-04-29T17:04:22Z</dc:date>
    <item>
      <title>Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011313#M1897284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know how to modify a read-only static attribute from a class enhancement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: I added GV_MY_ATTRIBUTE as a static (class) read-only attribute to the CL_A_STANDARD_CLASS class via the Z_MY_ENHANCEMENT enhancement. I added a pre-exit method to the CL_A_STANDARD_CLASS=&amp;gt;A_STATIC_STANDARD_METHOD static standard method via the &lt;SPAN style="font-size: 13.3333330154419px;"&gt;Z_MY_ENHANCEMENT enhancement&lt;/SPAN&gt;. How can I modify &lt;SPAN style="font-size: 13.3333330154419px;"&gt;GV_MY_ATTRIBUTE from the pre-exit?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, I don't want to create a public static setter to modify the attribute value, because I don't want it to be modifiable outside of the class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mathieu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 14:25:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011313#M1897284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-29T14:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011314#M1897285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a problem changing GV_MY_ATTRIBUTE from your pre-exit? I can imagine there might be, due to the way enhancements to classes are handled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Possible solutions:&lt;/P&gt;&lt;P&gt;Create a private static setter and call that from your pre-exit.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Define GV_MY_ATTRIBUTE as a private static, and only allow external access via a getter.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 14:30:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011314#M1897285</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2015-04-29T14:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011315#M1897286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It won't work: if the setter is private or protected, it can not be called from within the enhancement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 14:41:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011315#M1897286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-29T14:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011316#M1897287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Create another class which has the SAP class as a friend. Put GV_MY_ATTRIBUTE as a private static attribute of this new class, and create a public getter.... or... make GV_MY_ATTRIBUTE a public read only attribute of the new class, can create a private setter for it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 14:56:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011316#M1897287</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2015-04-29T14:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011317#M1897288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure I want to create a class just for this ^^ Wouldn'it a bit weird to create a class that only contains an attribute and a setter? Isn't there a more direct, simpler method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Isn't it possible to use the core_object enhancement object (that represents the current instance of the class that is enhanced, in other words, "me") to access the class itself?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 15:07:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011317#M1897288</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-29T15:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011318#M1897289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Meister Matthew! &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" src="https://community.sap.com/1273/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P class="almost_half_cell"&gt;&lt;/P&gt;&lt;DIV dir="ltr"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Excuse my&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;ignorance&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;but the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;READ ONLY&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;statement is not&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;only&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;used to&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;read&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the public&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;attribute,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;blocking&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;overwritten&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;I believe that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;using&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;SETTER&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;/&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;GETTER&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;help&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in this case.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV dir="ltr"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 15:19:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011318#M1897289</guid>
      <dc:creator>raphael_almeida</dc:creator>
      <dc:date>2015-04-29T15:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011319#M1897290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When an attribute is read-only, you can read it from outside its class / instance, and you can modify it &lt;STRONG&gt;only&lt;/STRONG&gt; from within its class / instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words, it allows to avoid to create a getter (as the attribute is public) but without the "danger" for the attribute to be modified by "someone else" (another object / class than the object / class it belongs to).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem I have is that the attribute is part of a class' enhancement and the enhancement is considered as "someone else" than the class. Therefore, the only solution is to make the attribute as NON read-only, which I don't want because I don't want the attribute to be modifed outside of the class, or to create a public setter that I call from the enhancement, which I don't want either for the same reason.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 15:36:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011319#M1897290</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-29T15:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011320#M1897291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Might a protected setter do the job?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 16:37:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011320#M1897291</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-29T16:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011321#M1897292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It depends how SAP technically manage the enhancement. If it's a subclass, it should work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 17:01:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011321#M1897292</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2015-04-29T17:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011322#M1897293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Obviously that would be ideal, but the enhancement of classes isn't (as you've found) entirely straightforward - so some convoluted solution might be the only way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see a problem with creating a small class for one specific purpose. I've often done it. More often in Java, for sure, but also in ABAP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Apr 2015 17:04:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011322#M1897293</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2015-04-29T17:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Modify read-only static attribute from a class enhancement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011323#M1897294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As already told, "&lt;SPAN style="color: #333333; font-size: 12px;"&gt;if the setter is private or protected, it can not be called from within the enhancement". &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately (?), an enhancement is not a sublcass of the enhanced class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I did it! I made the enhancement a sublass of the enhanced class and I have been able to modify directly the class read-only attribute, without using a public setter &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.sap.com/1273/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I went to my enhancement code and changed:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CLASS lcl_z_my_enhancement DEFINITION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PUBLIC SECTION.&lt;/P&gt;
&lt;P&gt;[...]&lt;/P&gt;
&lt;P&gt;ENDCLASS.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "LCL_Z_MY_ENHANCEMENT&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CLASS lcl_z_my_enhancement DEFINITION INHERITING FROM cl_a_standard_class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PUBLIC SECTION.&lt;/P&gt;
&lt;P&gt;[...]&lt;/P&gt;
&lt;P&gt;ENDCLASS.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "LCL_Z_MY_ENHANCEMENT&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And then:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CLASS lcl_z_my_enhancement IMPLEMENTATION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; METHOD constructor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; me-&amp;gt;core_object = core_object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ENDMETHOD.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "CONSTRUCTOR&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CLASS lcl_z_my_enhancement IMPLEMENTATION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; METHOD constructor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; super-&amp;gt;constructor( ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; me-&amp;gt;core_object = core_object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ENDMETHOD.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "CONSTRUCTOR&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After that, I have been able to do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;gv_my_attribute = a_value.&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if gv_my_attribute is read-only.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Apr 2015 08:20:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/modify-read-only-static-attribute-from-a-class-enhancement/m-p/11011323#M1897294</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-04-30T08:20:04Z</dc:date>
    </item>
  </channel>
</rss>

