Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting error while creating abstract method

suresh_s9
Participant
0 Likes
2,549

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,662

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,663

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,662

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

Read only

0 Likes
1,662

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

Read only

0 Likes
1,662

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

Read only

suresh_s9
Participant
0 Likes
1,662

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.