10-29-2007 10:42 AM
Hello,
I am not able to create multiple constructors inside a Global Class in SE24.
Once i create 1st constructor, the button as well as menu item is automatically disabled.
I have identified that this problem also occurs when i make the 1st constructor passing parameters. In that case, the ABAP program refuses creation of an object without passing values to that object attributes.
I have also tried creating multiple constructors identical to C++ method. i.e. Giving the same name to constructors as that of class name and changing the number/type of parameters that are passed. But ABAP refuses to identify that method as constructor and furthermore multiple methods with the same class name can not be created.
Can anyone have solution to this??
Thanks for your valuable time...
10-29-2007 12:23 PM
Hi Amar,
In ABAP Objects we can use two types of constructor methods: INSTANCE CONSTRUCTOR and STATIC CONSTRUCTOR.
The constructors are Identified by reserved name "CONSTRUCTOR" to INSTANCE CONSTRUCTOR and "CLASS_CONSTRUCTOR" to STATIC CONSTRUCTOR.
Only two constructors is allowed per class one is "CONSTRUCTOR" and other is "CLASS_CONSTRUCTOR", and doesn't allowed to modify or overwrite its signature.
<b>I Noted that is your first Post, so don't forget to read all <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/HOME/RulesofEngagement&">RULES</a> and close this thread when your question be answer !</b>
Regards.
Marcelo Ramos
10-29-2007 11:04 AM
Hi Amar,
OOABAP does not support polymorphism unlike C++. i.e you cannot have more than one mehtod with same name but different signature..
regards,
Piyush
10-29-2007 12:23 PM
Hi Amar,
In ABAP Objects we can use two types of constructor methods: INSTANCE CONSTRUCTOR and STATIC CONSTRUCTOR.
The constructors are Identified by reserved name "CONSTRUCTOR" to INSTANCE CONSTRUCTOR and "CLASS_CONSTRUCTOR" to STATIC CONSTRUCTOR.
Only two constructors is allowed per class one is "CONSTRUCTOR" and other is "CLASS_CONSTRUCTOR", and doesn't allowed to modify or overwrite its signature.
<b>I Noted that is your first Post, so don't forget to read all <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/HOME/RulesofEngagement&">RULES</a> and close this thread when your question be answer !</b>
Regards.
Marcelo Ramos
11-08-2011 4:57 AM
Hi Marcelo,
I have some confusion about constructor's............. i know that constructor's are automatically called when ever we create an object for a respective class............may i know what is the exact use of these constructor's ? and why they are automatically called?please resolve my doubt.
Regards,
Venkatt
Moderator Message: Please read the documentation on instance CONSTRUCTORs. Also post a separate thread for your query.
Edited by: Suhas Saha on Nov 8, 2011 10:36 AM