03-13-2007 7:38 AM
Hi All,
I am beginner of ABAP objects.
REPORT example.
----
CLASS counter DEFINITION
----
*
----
CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS : set IMPORTING value(set_value) TYPE i,
increment,
get EXPORTING value(get_value) TYPE i.
PRIVATE SECTION.
DATA : count TYPE i.
ENDCLASS. "counter DEFINITION.
----
CLASS counter IMPLEMENTATION
----
*
----
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD. "set
METHOD increment.
count = count + 1.
ENDMETHOD. "increment
METHOD get.
get_value = count.
ENDMETHOD. "get
ENDCLASS. "counter IMPLEMENTATION
DATA cnt TYPE REF TO counter.
CREATE OBJECT cnt.
DATA : number TYPE i VALUE 5.
CALL METHOD cnt->set
EXPORTING
set_value = number.
DO 3 TIMES.
CALL METHOD cnt->increment.
ENDDO.
call method cnt->get
importing get_value = number.
It is giving error like Stament is not accessbile
please help
03-13-2007 7:46 AM
I got the Answer.
I missed the START-OF-SELECTION , before creating the object.
regards,
anjireddi
03-13-2007 9:52 AM
03-16-2007 8:34 AM
yes......Instantiation and declaration cannot happen in the same event...
Instantiation is generally done in the start of selection
03-16-2007 3:09 PM
Hi Raman,
In case if you are interested in understanding why you got the error because of not using Start_of_selection, please check out the thread.
https://forums.sdn.sap.com/click.jspa?searchID=1653133&messageID=3017631
Regards
Indrajit