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

Call an abstract method

Nicolas
Active Contributor
0 Likes
2,163

Hello developers,

I am trying to implement the following (simple) classes:

class abstract_class definition abstract

     public

     create public .

     ...

     protected section

          methods parse_string abtract

               importing

                    value(i_str) type string.

         

          methods to_table.

     ...

endclass.

class abstract_class implementation.

     method to_table.

          ...

          me->parse_string( str ).

          ...

     endmethod.

endclass.

*---------------------------------------------------------------------------*

class other_class definition

     public

          inheriting from abstract_class

          final

          create public .

     ...

     protected section.

          methods parse_string redefinition.

     ...

endclass.

class other_class implementation.

     method parse_string.

*        some codes         

     endmethod.

endclass.

I have instantiated the class other_class. But when I call the method to_table, I am getting the error "CALL METHOD NOT IMPLEMENTED" on the method parse_string. Where is my mistake ?

Thank you for your replies.

Best regards,

Nicolas

1 ACCEPTED SOLUTION
Read only

Nicolas
Active Contributor
0 Likes
1,495

Hello everyone,

First of all, thank you for all your reply.

During the night, I have thought to my problem and I found the solution. In fact, I made a (very) great mistake. Here is my code:

CLASS abstract_class IMPLEMENTATION.

     method constructor.

          me->to_table( ).

     endmethod.

  

     method to_table.

          ...

          me->parse_string( a_string ).

          ...

     endmethod.

ENDCLASS.

CLASS other_class IMPLEMENTATION.

     method constructor.

          call method super->constructor.

     endmethod.

     method parse_string.

*          some code

     endmethod.

ENDCLASS.

The problem is: I call the method parse_string of my child class (with the instruction me->parse_string) before my child class is instantiated... (Now, I can jump out the window.)

Hello developers,

I am trying to implement the following (simple) classes:

class abstract_class definition abstract

     public

     create public .

     ...

     protected section

          methods parse_string abtract

               importing

                    value(i_str) type string.

         

          methods to_table.

     ...

endclass.

class abstract_class implementation.

     method to_table.

          ...

          me->parse_string( str ).

          ...

     endmethod.

endclass.

*---------------------------------------------------------------------------*

class other_class definition

     public

          inheriting from abstract_class

          final

          create public .

     ...

     protected section.

          methods parse_string redefinition.

     ...

endclass.

class other_class implementation.

     method parse_string.

*        some codes         

     endmethod.

endclass.

I have instantiated the class other_class. But when I call the method to_table, I am getting the error "CALL METHOD NOT IMPLEMENTED" on the method parse_string. Where is my mistake ?

Thank you for your replies.

Best regards,

Nicolas

7 REPLIES 7
Read only

Former Member
0 Likes
1,495

This message was moderated.

Read only

Former Member
0 Likes
1,495

Hi Nicolas,

Can you upload a txt of your code so it could be analyzed it is difficult to see like this...

Thanks

Read only

former_member205488
Active Participant
0 Likes
1,495

Hello, Nicolas!

How did you instantiated the object? How did you called the method? Could I look at your code?

If you did it like this, it should work fine:

DATA: lo_other TYPE REF TO other_class

CREATE OBJECT lo_other.

lo_other->to_table( ).

Read only

Former Member
0 Likes
1,495

Hello Nicolas,

Abstract classes are only for declaration. You can not implement them. Remove the implementation of your abstract class. (comment out or delete the following lines of code from you program and check again:).

class abstract_class implementation.

     method to_table.

          ...

          me->parse_string( str ).

          ...

     endmethod.

endclass.



You can only implement the subclasses of the abstract class.




Thanks,


John.

Read only

matt
Active Contributor
0 Likes
1,495

But John, to_table isn't abstract. The abstract method is parse_string.


To really help, we need the code where you instantiate the class and call the method. As it stands, there are no accessible methods in the class - they're all protected. There is not one that is public.

Read only

Former Member
0 Likes
1,495

hi,

did u call the object of the class other_class.i think you have called the abstract class (abstract_class)object .



Read only

Nicolas
Active Contributor
0 Likes
1,496

Hello everyone,

First of all, thank you for all your reply.

During the night, I have thought to my problem and I found the solution. In fact, I made a (very) great mistake. Here is my code:

CLASS abstract_class IMPLEMENTATION.

     method constructor.

          me->to_table( ).

     endmethod.

  

     method to_table.

          ...

          me->parse_string( a_string ).

          ...

     endmethod.

ENDCLASS.

CLASS other_class IMPLEMENTATION.

     method constructor.

          call method super->constructor.

     endmethod.

     method parse_string.

*          some code

     endmethod.

ENDCLASS.

The problem is: I call the method parse_string of my child class (with the instruction me->parse_string) before my child class is instantiated... (Now, I can jump out the window.)