Skip to Content
0
Former Member
Feb 16, 2006 at 03:55 PM

ABAP OOPS

19 Views

Hi all,

I am trying to learn OOP's concepts oin ABAP.I wrote a very small program but it gives me an error saying <b>"Statement not accessible"</b>. I am forwarding my whole code, please eplain me where I am going wrong.

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

REPORT zclass_demo.

----


  • CLASS C_COUNTER DEFINITION

----


CLASS c_counter DEFINITION.

PUBLIC SECTION.

METHODS: set_counter IMPORTING value(set_value) TYPE i,

increment_counter,

get_counter EXPORTING value(get_value) TYPE i.

PRIVATE SECTION.

DATA count TYPE i.

ENDCLASS. "C_COUNTER DEFINITION

----


  • CLASS C_COUNTER IMPLEMENTATION

----


CLASS c_counter IMPLEMENTATION.

METHOD set_counter.

count = set_value.

ENDMETHOD. "SET_COUNTER

METHOD increment_counter.

ADD 1 TO count.

ENDMETHOD. "INCREMENT_COUNTER

METHOD get_counter.

get_value = count.

ENDMETHOD. "GET_COUNTER

ENDCLASS. "C_COUNTER IMPLEMENTATION

*---- Data Statement

DATA cref1 TYPE REF TO c_counter.

<u><b>CREATE OBJECT cref1.</b></u>

DATA num TYPE i VALUE 5.

CALL METHOD cref1->set_counter

EXPORTING

set_value = number.

DO 3 TIMES.

CALL METHOD cfref1->increment_counter.

ENDDO.

CALL METHOD cref1->get_counter

IMPORTING

get_value = number.

WRITE number.

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

The problem is with the underlined line of the code.

Regards,

Varun.