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 oops program

Former Member
0 Likes
527

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
502

Hi,

try it now. the error is because of gap after > symbol in statement

call method:CLASS-> DISPLAY.


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.

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

START-OF-SELECTION.

DATA: CLASS TYPE REF TO class.

CREATE OBJECT: CLASS.

call method:CLASS->DISPLAY.

rgds,

bharat,

4 REPLIES 4
Read only

Former Member
0 Likes
502

where is your class definition?

Read only

Former Member
0 Likes
503

Hi,

try it now. the error is because of gap after > symbol in statement

call method:CLASS-> DISPLAY.


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.

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

START-OF-SELECTION.

DATA: CLASS TYPE REF TO class.

CREATE OBJECT: CLASS.

call method:CLASS->DISPLAY.

rgds,

bharat,

Read only

0 Likes
502

Thank u bharat

Read only

Former Member
0 Likes
502

Change your code , there is a gap between -> method

REPORT  ZTEST_CODE.

class c1 definition.
PUBLIC SECTION.

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

METHODS:DISPLAY.

ENDCLASS.



CLASS C1 IMPLEMENTATION.

METHOD DISPLAY.
WRITE:/ 'THIS METHOD TO DISPLAY'.
ENDMETHOD.
ENDCLASS.

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

START-OF-SELECTION.

DATA: CLASS TYPE REF TO c1.

CREATE OBJECT: CLASS.

*WRITE:/ CLASS->WTEXT.
call method:
CLASS->DISPLAY.