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

Regarding sample oops program

Former Member
0 Likes
645

Hi all,

I have done simple oops program. the program is below

class class definition . It is throwing error Method *** is unknown or protected or private.

PUBLIC SECTION.

DATA : WTEXT(40) VALUE 'ABAP OBJECTS'.

METHODS:DISPLAY.

ENDCLASS.

&----


*&

  • class c1 IMPLEMENTATION

*&

&----


CLASS Class IMPLEMENTATION.

METHOD DISPLAY.

WRITE:/ ' THIS METHOD TO DISPLAY'.

ENDMETHOD.

ENDCLASS.

*********************

START-OF-SELECTION.

DATA: CLASS TYPE REF TO class.

CREATE OBJECT: CLASS.

*WRITE:/ CLASS->WTEXT.

call method:

CLASS-> DISPLAY.

It is throwing error Method *** is unknown or protected or private.

Please rectify the error.

thanks &rgds

vvvvvv

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
611

Hi,

The error in your program is remove the space before display.This solve your problem.

replace call method CLASS-> DISPLAY with CAll method CLASS->DISPLAY.

Reward if useful.

Regards,

Swetha.

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
611

Hello

You should not use ABAP keywords (CLASS) as name of your class. Replace it with lcl_myclass or something else.

Regards

Uwe

Read only

Former Member
0 Likes
612

Hi,

The error in your program is remove the space before display.This solve your problem.

replace call method CLASS-> DISPLAY with CAll method CLASS->DISPLAY.

Reward if useful.

Regards,

Swetha.

Read only

Former Member
0 Likes
611

rather thaen you can create ref of other name bkz it is calling class method

Read only

Former Member
0 Likes
611

Hi,

class class definition .

PUBLIC SECTION.

DATA : WTEXT(40) VALUE 'ABAP OBJECTS'.

METHODS:DISPLAY.

ENDCLASS.

CLASS Class IMPLEMENTATION.

METHOD DISPLAY.

WRITE:/ ' THIS METHOD TO DISPLAY'.

ENDMETHOD.

ENDCLASS.

DATA: CLASS TYPE REF TO class.

START-OF-SELECTION.

CREATE OBJECT: CLASS.

*WRITE:/ CLASS->WTEXT.

call method CLASS->display.