‎2011 Mar 29 5:35 PM
hi folks,
i facing issue for ABSTRACT Class.
I am trying to create abstarct method, (refered example from saptechnical site),
I created one attribute i-num, created one method AREA, in implementation area , i made it as Abstract, then i did syntax check, then it is giving below error.
*Class ZTEST_CLASS01_AB,Method AREA
The abstract method "AREA" can only be implemented after its
redefinition (METHODS AREA REDEFINITION).*
i tried all the ways..
created subclass for this, i writted some code in AREA of Sub-class, there it is giving dump, because first one is not activated properly..
could you please somebody help me on this.
Sri
‎2011 Mar 29 8:32 PM
Halo Sri,
Step 1
Create a class(ZABSTRACT) and make its type as Abstract( Which means atleast one of its methods is abstract)
Step2
Create a method (AREA) inside class ZABSTRACT .Mark this method as ABSTRACT in the definition part( In Se24 you should check this in the detail button) .This method cannot have any implementation , only definition.
Step3
Activate the class ZABSTRACT.
Step4
Now create another class ZSUB inheriting from ZABSTRACT.
Step5
Redefine the Method (AREA) and write the implementation. Activate ZSUB Class also
Regards
Arshad
‎2011 Mar 29 8:32 PM
Halo Sri,
Step 1
Create a class(ZABSTRACT) and make its type as Abstract( Which means atleast one of its methods is abstract)
Step2
Create a method (AREA) inside class ZABSTRACT .Mark this method as ABSTRACT in the definition part( In Se24 you should check this in the detail button) .This method cannot have any implementation , only definition.
Step3
Activate the class ZABSTRACT.
Step4
Now create another class ZSUB inheriting from ZABSTRACT.
Step5
Redefine the Method (AREA) and write the implementation. Activate ZSUB Class also
Regards
Arshad
‎2011 Mar 30 7:27 AM
Hello Arshad,
Create a class(ZABSTRACT) and make its type as Abstract( Which means atleast one of its methods is abstract)
We can have abstract classes with all it's methods as non-abstract or concrete. A small example is given below:
CLASS gcl_abstract DEFINITION ABSTRACT.
PUBLIC SECTION.
METHODS concrete. "Concrete
ENDCLASS. "gcl_abstract DEFINITION
*----------------------------------------------------------------------*
* CLASS gcl_abstract IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS gcl_abstract IMPLEMENTATION.
METHOD concrete.
WRITE: / `I'm a concrete method`.
ENDMETHOD. "concrete
ENDCLASS. "gcl_abstract IMPLEMENTATION
*----------------------------------------------------------------------*
* CLASS gcl_abstract_sub DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS gcl_abstract_sub DEFINITION INHERITING FROM gcl_abstract.
PUBLIC SECTION.
METHODS concrete REDEFINITION.
ENDCLASS. "gcl_abstract_sub DEFINITION
*----------------------------------------------------------------------*
* CLASS gcl_abstract_sub IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS gcl_abstract_sub IMPLEMENTATION.
METHOD concrete.
super->concrete( ).
WRITE: / 'Abstract class might not have abstract methods at all!'.
ENDMETHOD. "concrete
ENDCLASS. "gcl_abstract_sub IMPLEMENTATION
START-OF-SELECTION.
DATA: go_abstract TYPE REF TO gcl_abstract_sub.
CREATE OBJECT go_abstract.
go_abstract->concrete( ).Although i will agree there is no point in making a class as abstract & having no abstract method
@Sri: Looks like you're trying to implement the abstract method "AREA" in the abstract class hence the error. For abstract method you cannot define their implementation in the corres. abstract class.
BR,
Suhas
Edited by: Suhas Saha on Mar 30, 2011 12:04 PM
‎2011 Mar 30 8:56 AM
Halo Suhas,
Thanks for the reply . Its a new information for me . I thought the compiler would yell at you for the below scenario.
But what I meant in my note was if you have an abstract method then the class should be always abstract .
Good to have this kind of discussions
Regards
Arshad
‎2011 Mar 30 9:32 AM
Hi Arshad,
I found one thing today, i created a class as Public, created one method, made it as Abstract, activated it,then when i verified the class properties ,its changed to Abstract from Public.
so we can conclude now if any one of the method is Abstract , class will become automatically Abstract,
please correct me if it is wrong.
Sri
‎2011 Mar 30 7:39 AM
thank you for your time,i have deleted these two classes from se24, again i created, it is working fine with out any issues.i dont know how it is workign now, yesterday also i tried the same way.