<?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: Read-only addition while declaring the public attribute in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456131#M1056325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since your attribute is public, you can access - Read and UPDATE - it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if you don't want the external application to modify the content of the attribute, you have to use the READ-ONLY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS LCL_TEST DEFINITION.
  PUBLIC SECTION .
    DATA: P_NUM1 TYPE I READ-ONLY,
          P_NUM2 TYPE I.

    METHODS: SET_VALUE.

ENDCLASS.                    "lcl_test DEFINITION

CLASS LCL_TEST IMPLEMENTATION.
  METHOD SET_VALUE.
    P_NUM1 = 10.
    P_NUM2 = 20.
  ENDMETHOD.                    "set_value
ENDCLASS.                    "lcl_test IMPLEMENTATION

START-OF-SELECTION.
  DATA: O_TEST TYPE REF TO LCL_TEST.

  CREATE OBJECT O_TEST.

  CALL METHOD O_TEST-&amp;gt;SET_VALUE.

  WRITE: / O_TEST-&amp;gt;P_NUM1,
         / O_TEST-&amp;gt;P_NUM2.

** o_Test-&amp;gt;p_num1 = 30.    " This gives the Syntax error
* Write access to the READ-ONLY attribute "P_NUM1" is not allowed outside
* the class. outside the class.

  O_TEST-&amp;gt;P_NUM2 = 40.

  WRITE: / O_TEST-&amp;gt;P_NUM1,
         / O_TEST-&amp;gt;P_NUM2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Sep 2008 15:32:15 GMT</pubDate>
    <dc:creator>naimesh_patel</dc:creator>
    <dc:date>2008-09-03T15:32:15Z</dc:date>
    <item>
      <title>Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456130#M1056324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can any one please let me know the read-only key word while declaring the public attributes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ur explanations are graeatly welcome instead of links.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2008 15:24:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456130#M1056324</guid>
      <dc:creator>radhushankar</dc:creator>
      <dc:date>2008-09-03T15:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456131#M1056325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since your attribute is public, you can access - Read and UPDATE - it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if you don't want the external application to modify the content of the attribute, you have to use the READ-ONLY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS LCL_TEST DEFINITION.
  PUBLIC SECTION .
    DATA: P_NUM1 TYPE I READ-ONLY,
          P_NUM2 TYPE I.

    METHODS: SET_VALUE.

ENDCLASS.                    "lcl_test DEFINITION

CLASS LCL_TEST IMPLEMENTATION.
  METHOD SET_VALUE.
    P_NUM1 = 10.
    P_NUM2 = 20.
  ENDMETHOD.                    "set_value
ENDCLASS.                    "lcl_test IMPLEMENTATION

START-OF-SELECTION.
  DATA: O_TEST TYPE REF TO LCL_TEST.

  CREATE OBJECT O_TEST.

  CALL METHOD O_TEST-&amp;gt;SET_VALUE.

  WRITE: / O_TEST-&amp;gt;P_NUM1,
         / O_TEST-&amp;gt;P_NUM2.

** o_Test-&amp;gt;p_num1 = 30.    " This gives the Syntax error
* Write access to the READ-ONLY attribute "P_NUM1" is not allowed outside
* the class. outside the class.

  O_TEST-&amp;gt;P_NUM2 = 40.

  WRITE: / O_TEST-&amp;gt;P_NUM1,
         / O_TEST-&amp;gt;P_NUM2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2008 15:32:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456131#M1056325</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2008-09-03T15:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456132#M1056326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Radhu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Quite often you will find ABAP classes where key instance attributes are public yet read-only. Examples:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF_PT_EMPLOYEE~PERNR of CL_PT_EMPLOYEE
IF_RECN_CONTRACT~MS_DETAIL of CL_RECN_CONTRACT&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Advantage is that you do not need an explicit GET method to retrieve these key attributes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2008 18:57:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456132#M1056326</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-09-03T18:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456133#M1056327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA : var type &amp;lt;type&amp;gt; read-only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The READ_ONLY addition means that a public attribute declared with DATA can br read from outside but can only be changed by methods of the class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : You can currently use READ-ONLY in public visibility section of class declartion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Sep 2008 19:02:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456133#M1056327</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-03T19:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456134#M1056328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shankar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Read-Only property specified for Public attributes is to provide the restrictions or to specify&lt;/P&gt;&lt;P&gt;the restrictions such that that particular method cannot be modified..  In general the Read-only&lt;/P&gt;&lt;P&gt;property is set if and only if the method is used particularly for Retrieving data or for any other &lt;/P&gt;&lt;P&gt;Retrieval process such that no other class or method cannot use that or change the nature of&lt;/P&gt;&lt;P&gt;that method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read-only properties are only set if the nature of the method should not be changed and also if &lt;/P&gt;&lt;P&gt;it is only used for retrieving data..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this would help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Narin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 02:49:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456134#M1056328</guid>
      <dc:creator>narin_nandivada3</dc:creator>
      <dc:date>2008-09-04T02:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456135#M1056329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This message was moderated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 04:39:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456135#M1056329</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T04:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456136#M1056330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  If a public attribute is declared with READ ONLY addition. Then only methods of that class can change this attribute.&lt;/P&gt;&lt;P&gt;It can only be read from outside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Abhijeet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 04:48:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456136#M1056330</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T04:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Read-only addition while declaring the public attribute</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456137#M1056331</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;By using Read only your are making your variable protective. By default Public variables are accessible from out side and they can also be updated from outside. By using read only option you can only read the data from outside but you can not modify the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naresh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 05:08:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-only-addition-while-declaring-the-public-attribute/m-p/4456137#M1056331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T05:08:48Z</dc:date>
    </item>
  </channel>
</rss>

