<?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: Constructor Vs. Method Qustion in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487550#M1062277</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The constructor is nothiing else but a method which is called automatically when the class is instantiated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Sep 2008 07:44:43 GMT</pubDate>
    <dc:creator>rainer_hbenthal</dc:creator>
    <dc:date>2008-09-04T07:44:43Z</dc:date>
    <item>
      <title>Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487549#M1062276</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 learn now about constructor in Abap and my question is ,&lt;/P&gt;&lt;P&gt;what is the &lt;STRONG&gt;&lt;U&gt;advantage  and disadvantage&lt;/U&gt;&lt;/STRONG&gt; of using constructor oo,that i can build method that do the same  action&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Regular Method:

    METHODS: set_attributes IMPORTING
             im_name TYPE string
             im_planetype TYPE saplane-planetype,
             display_attributes.

Constructor :


    METHODS: constructor IMPORTING
    im_name TYPE string
    im_planetype TYPE saplane-planetype,
    display_attributes.

in the constructor i use:

  CREATE OBJECT r_plane
    EXPORTING
      im_name      = 'LH_Barlin'
      im_planetype = 'a321'.

and in Method :

 CREATE OBJECT r_plane.
  r_plane-&amp;gt;set_attributes( im_name = 'LH_usa' im_planetype = 'bbb' ).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;and both commend do the same :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 07:38:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487549#M1062276</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T07:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487550#M1062277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The constructor is nothiing else but a method which is called automatically when the class is instantiated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 07:44:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487550#M1062277</guid>
      <dc:creator>rainer_hbenthal</dc:creator>
      <dc:date>2008-09-04T07:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487551#M1062278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cosmo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  refer to the link :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b552f7d30911d2b467006094192fe3/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b552f7d30911d2b467006094192fe3/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With luck,&lt;/P&gt;&lt;P&gt;Pritam.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 07:47:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487551#M1062278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T07:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487552#M1062279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rainer Hübenthal  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if i can do it in method so way to have it (constructor) ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 08:02:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487552#M1062279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T08:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487553#M1062280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  In constructor the method  will execute automatically when the class has been instanced.&lt;/P&gt;&lt;P&gt;But for the normal method we have to call the method explicitly.&lt;/P&gt;&lt;P&gt;In some cases we need constructor so that some piece of code is executed automatically when the class is initiated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Manjari.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 08:07:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487553#M1062280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-04T08:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487554#M1062281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First,  you should post these questions in the ABAP Objects forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, you use the constructor to &lt;STRONG&gt;force&lt;/STRONG&gt; certain actions when the instance is created.  If you as designer of the class require that two attributes be set, then making them obligatory parameters ensures that an object can't be instantiated without those parameters being given some values.  You could include some validation in the constructor as well to make sure that the values are valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't put them in a constructor, you are relying on future developers - possibly even yourself - remembering to set those parameters after they've created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One other advantage - it's one line of ABAP instead of three!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As ever though, which is better comes down to what specifically you're trying to do.  It is usually better programming practice to leave as little to luck and remembering, as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2008 08:18:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487554#M1062281</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-09-04T08:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Constructor Vs. Method Qustion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487555#M1062282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cosmo Kramer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check these threads..&lt;/P&gt;&lt;P&gt;/message/5904557#5904557 &lt;B&gt;[original link is broken]&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="953895"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="946910"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please go through the below SAP HELP&lt;/P&gt;&lt;P&gt;[Constructor Vs Method |http://help.sap.com/erp2005_ehp_03/helpdata/EN/08/d27c03b81011d194f60000e8353423/content.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this would help you to understand the difference..&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 08:21:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-vs-method-qustion/m-p/4487555#M1062282</guid>
      <dc:creator>narin_nandivada3</dc:creator>
      <dc:date>2008-09-04T08:21:48Z</dc:date>
    </item>
  </channel>
</rss>

