<?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 an Abstract class in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821831#M919155</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Theoretically we can create a constructor in abstract class.&lt;/P&gt;&lt;P&gt;But we do not have implementation in that.&lt;/P&gt;&lt;P&gt;constructor will be called when we are creating object.&lt;/P&gt;&lt;P&gt;For abstract class we are not able to create object.&lt;/P&gt;&lt;P&gt;We can inherit that constructor and then we can call in child class constructor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sarath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 07 Jun 2008 04:53:30 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-07T04:53:30Z</dc:date>
    <item>
      <title>constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821828#M919152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can we have a constructor in an Abstract class??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2008 11:16:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821828#M919152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-14T11:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821829#M919153</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;We can't have a constructor method in abstract classe, take a look at this: &lt;SPAN __jive_macro_name="thread" id="720587"&gt;&lt;/SPAN&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>Wed, 14 May 2008 11:23:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821829#M919153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-14T11:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821830#M919154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You might be able to achieve your functionality by using a concrete class and interfaces.  It depends what you're trying to achieve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2008 12:45:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821830#M919154</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-05-14T12:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821831#M919155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Theoretically we can create a constructor in abstract class.&lt;/P&gt;&lt;P&gt;But we do not have implementation in that.&lt;/P&gt;&lt;P&gt;constructor will be called when we are creating object.&lt;/P&gt;&lt;P&gt;For abstract class we are not able to create object.&lt;/P&gt;&lt;P&gt;We can inherit that constructor and then we can call in child class constructor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;sarath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2008 04:53:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821831#M919155</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-07T04:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821832#M919156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Harshu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course you can have a CONSTRUCTOR within an abstract class. Such a CONSTRUCTOR method can be used to preset values for inherited attributes. Obviously if we can have a CONSTRUCTOR method we can put any kind of implementation into it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For abstract class we are not able to create object.&lt;/P&gt;&lt;P&gt;We can inherit that constructor and then we can call in child class constructor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;CONSTRUCTOR methods are the only public methods which are NOT inherited. It is wrong to say that we can call the CONSTRUCTOR in sub-classes but we MUST call super-&amp;gt;CONSTRUCTOR otherwise we get a syntax error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a look at sample report &lt;STRONG&gt;ZUS_SDN_ABSTRACT_CLASS&lt;/STRONG&gt; (the same logic holds for global classes):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_ABSTRACT_CLASS
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Thread: constructor in an Abstract class
*&amp;amp; &amp;lt;a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="862886"&amp;gt;&amp;lt;/a&amp;gt;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_abstract_class.


*----------------------------------------------------------------------*
*       CLASS lcl_abstract DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_abstract DEFINITION ABSTRACT.

  PUBLIC SECTION.

    METHODS: constructor.

  PROTECTED SECTION.
    DATA: md_counter  TYPE i.
ENDCLASS.                    "lcl_abstract DEFINITION



*----------------------------------------------------------------------*
*       CLASS lcl_abstract IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_abstract IMPLEMENTATION.

  METHOD constructor.
    WRITE: / 'CONSTRUCTOR of abstract class'.

    md_counter = 5. " preset counter with value
  ENDMETHOD.                    "constructor


ENDCLASS.                    "lcl_abstract IMPLEMENTATION



*----------------------------------------------------------------------*
*       CLASS lcl_subclass DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_subclass DEFINITION INHERITING FROM lcl_abstract.

  PUBLIC SECTION.

    METHODS: constructor,
             get_counter.


ENDCLASS.                    "lcl_subclass DEFINITION


*----------------------------------------------------------------------*
*       CLASS lcl_subclass IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_subclass IMPLEMENTATION.

  METHOD constructor.
    super-&amp;gt;constructor( ).  " syntax error if not called
    WRITE: / 'CONSTRUCTOR of sub-class'.
  ENDMETHOD.                    "constructor

  METHOD get_counter.
    WRITE: / 'Counter =', me-&amp;gt;md_counter.
  ENDMETHOD.                    "get_counter

ENDCLASS.                    "lcl_subclass IMPLEMENTATION


DATA: go_subclass   TYPE REF TO lcl_subclass.


START-OF-SELECTION.

  CREATE OBJECT go_subclass.
  SKIP.
  go_subclass-&amp;gt;get_counter( ).

" OUTPUT:
" CONSTRUCTOR of abstract class
" CONSTRUCTOR of sub-class
"
" Counter =          5

END-OF-SELECTION.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Sun, 08 Jun 2008 00:17:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821832#M919156</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-06-08T00:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821833#M919157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;refer to this example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  zsr_demo1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS c1 DEFINITION ABSTRACT.&lt;/P&gt;&lt;P&gt;  public section.&lt;/P&gt;&lt;P&gt;   methods constructor.&lt;/P&gt;&lt;P&gt;  PROTECTED SECTION.&lt;/P&gt;&lt;P&gt;    METHODS m1.&lt;/P&gt;&lt;P&gt;  PRIVATE SECTION.&lt;/P&gt;&lt;P&gt;    DATA a1 TYPE string VALUE `Attribute A1 of class C1`.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS c2 DEFINITION INHERITING FROM c1 FINAL.&lt;/P&gt;&lt;P&gt;  PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;    METHODS m2.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS c1 IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;  method constructor.&lt;/P&gt;&lt;P&gt;    write:'This is my first method'.&lt;/P&gt;&lt;P&gt; endmethod.&lt;/P&gt;&lt;P&gt;  METHOD m1.&lt;/P&gt;&lt;P&gt;    WRITE / a1.&lt;/P&gt;&lt;P&gt;  ENDMETHOD.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS c2 IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;  METHOD m2.&lt;/P&gt;&lt;P&gt;    m1( ).&lt;/P&gt;&lt;P&gt;  ENDMETHOD.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA oref TYPE REF TO c2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE OBJECT oref.&lt;/P&gt;&lt;P&gt;oref-&amp;gt;m2( ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 08:28:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821833#M919157</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T08:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821834#M919158</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;How can we have a constructor for an abstract class?? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all you can not create a object of an abstract class then how can we have a constructor for an abstract class and what is the need to have an constructor for an abstract class.&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>Tue, 10 Jun 2008 08:51:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821834#M919158</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-10T08:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: constructor in an Abstract class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821835#M919159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't &lt;EM&gt;instantiate&lt;/EM&gt; an abstract class but you &lt;EM&gt;can&lt;/EM&gt; have a constructor.  It is only ever called, however, when instantiating an object of a subclass.  ( Indeed, it MUST be called in the most recent releases ).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 09:48:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/constructor-in-an-abstract-class/m-p/3821835#M919159</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-06-10T09:48:50Z</dc:date>
    </item>
  </channel>
</rss>

