<?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 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028719#M716267</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Camila,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to define the parameters as optional as follow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    METHODS constructor 
              IMPORTING field1 TYPE char01 OPTIONAL
                        field2 TYPE char10 OPTIONAL.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the Processing of Constructor if you need you can use the statement 'IS SUPPLIED' to check is the parameters was used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  METHOD constructor.

    IF field1 IS SUPPLIED.
      ...
    ENDIF.

    ...

  ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcelo Ramos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Oct 2007 13:42:09 GMT</pubDate>
    <dc:creator>marcelo_ramos1</dc:creator>
    <dc:date>2007-10-30T13:42:09Z</dc:date>
    <item>
      <title>constructor</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028718#M716266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have created a class which has a constructor which imports the value of a and b.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for this particular class iam creating an object obj1 by exporting the values for a and b to the constructor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then iam creating an object called obj1 and obj2 without passing any parameters. because these objects should not execute that constructor rather it should call all the other methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for this program it shows an error message saying " the obligatory parameter A has no value assigned to it" at the lace where iam using create object obj2 and obj3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone help me what has to be done to resolve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Phyrose.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 12:13:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028718#M716266</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-30T12:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: constructor</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028719#M716267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Camila,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to define the parameters as optional as follow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    METHODS constructor 
              IMPORTING field1 TYPE char01 OPTIONAL
                        field2 TYPE char10 OPTIONAL.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;During the Processing of Constructor if you need you can use the statement 'IS SUPPLIED' to check is the parameters was used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  METHOD constructor.

    IF field1 IS SUPPLIED.
      ...
    ENDIF.

    ...

  ENDMETHOD.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcelo Ramos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 13:42:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028719#M716267</guid>
      <dc:creator>marcelo_ramos1</dc:creator>
      <dc:date>2007-10-30T13:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: constructor</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028720#M716268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Phyrose,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you define an instance constructor in your class, it would be called when ever you create an instance of a particular class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say you are going to create 3 instances of a class, your instance constructor would execute for 3 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot restrict that with out triggering, once you declare an Instance Constructor in your class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;Once you pass some importing parameters in a Constructor method, You should pass the parameters, while you create the object. If you do not pass any parameters it would throw an error.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the below code for the example of a Constructor.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  Y_TEMP_OOABAP.

*----------------------------------------------------------------------*
*       CLASS C1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS C1 DEFINITION.
  PUBLIC SECTION.
    METHODS: CONSTRUCTOR IMPORTING NUM1 TYPE I.
ENDCLASS.                    "C1 DEFINITION

*----------------------------------------------------------------------*
*       CLASS C1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS C1 IMPLEMENTATION.
  METHOD CONSTRUCTOR.
    WRITE:/ NUM1.
  ENDMETHOD.                    "CONSTRUCTOR
ENDCLASS.                    "C1 IMPLEMENTATION

START-OF-SELECTION.

DATA: OREF TYPE REF TO C1.

&amp;lt;b&amp;gt;CREATE OBJECT OREF EXPORTING NUM1 = 5.&amp;lt;/b&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above example an instance constructor will trigger for one time, when it comes to the create object statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As i have importing parameters to my constructor method, i must pass the exporting parameters while I create the object reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this clears your doubt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sreekanth&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;Reward each helpful answer.&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 14:14:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028720#M716268</guid>
      <dc:creator>sreekanthgo</dc:creator>
      <dc:date>2007-10-30T14:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: constructor</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028721#M716269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Phyrose&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &amp;lt;b&amp;gt;implicit &amp;lt;/b&amp;gt;CONSTRUCTOR (of root object &amp;lt;b&amp;gt;OBJECT&amp;lt;/b&amp;gt;) is only called if no CONSTRUCTOR method is defined for your class.&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>Tue, 30 Oct 2007 18:37:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028721#M716269</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-10-30T18:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: constructor</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028722#M716270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Camila,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Noted that you have a lot of unclosed thread, so I think you should read all &amp;lt;a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rules&lt;EM&gt;of&lt;/EM&gt;Engagement&amp;amp;"&amp;gt;POST'S RULES&amp;lt;/a&amp;gt; after you must close this and all yours thread that the question was answered !&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;Best Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcelo Ramos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2007 19:33:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor/m-p/3028722#M716270</guid>
      <dc:creator>marcelo_ramos1</dc:creator>
      <dc:date>2007-10-30T19:33:52Z</dc:date>
    </item>
  </channel>
</rss>

