12-19-2009 10:24 AM
12-19-2009 10:33 AM
Hello
Conceptually, we cannot create instance for an abstract class.
But, we can create object of the abstract class, do follow the below syntax.
create object <Ref to Abstract class> TYPE <Non Abstract class name>.
Hope this will help you
Subin
12-19-2009 10:27 AM
Please read SAP Help before posting.
We cannot create object of abstract class.
Check this link from SAP help to know more :
http://help.sap.com/saphelp_nw70/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
Hope this helps you.
Edited by: Harsh Bhalla on Dec 19, 2009 3:58 PM
12-19-2009 10:33 AM
Hello
Conceptually, we cannot create instance for an abstract class.
But, we can create object of the abstract class, do follow the below syntax.
create object <Ref to Abstract class> TYPE <Non Abstract class name>.
Hope this will help you
Subin
12-21-2009 1:31 PM
That does not create an object of the abstract class! It does create an object of a class which should be a sub class of the abstract base class. This could be used for dynamic instantiation or so.
@ Thread starter: You should the abstract class is normally a base class. You derive a sub class from this base class and implement or redefine the methods of the base class.
If you dont want created your own sub class, just look if the abstract class have been implemented. Maybe you can use the existing implemantations.
Bye Richard
12-21-2009 2:09 PM
As Richard Brünning mentioned in his reply, we can't instantiate the object with reference to the Abstract Class. i.e.
DATA: O_OBJ TYPE REF TO ZCL_ABS_CLASS.
CREATE O_OBJ. " << This will give syntax error
But you can surely use the abstract class to reference the object. At run time, based on your required you can instantiate the object with actual reference type to the subclass of the abstract class. Like:
DATA: O_OBJ TYPE REF TO ZCL_ABS_CLASS.
* ZCL_ABS_CLASS_SUB is sub class of the ZCL_ABS_CLASS
CREATE O_OBJ TYPE ZCL_ABS_CLASS_SUB.
Regards,
Naimesh Patel