2009 Jun 22 2:11 PM
Hi,
I'm getting a syntax error in the following code at last line saying 'Statemetn is not accessible'. Can some one tell me why it is not accessabile & what wrong in the code?
REPORT ztest_classes.
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
METHODS: fun1.
DATA: var1.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD fun1.
WRITE:/ 'Inside FUN1 of class1'.
ENDMETHOD. "fun1
ENDCLASS. "class1 IMPLEMENTATION
DATA: ref1 TYPE REF TO class1.
CREATE OBJECT ref1.
Regards,
Naga Sai Swapna
2009 Jun 22 2:18 PM
Hi,
Try
START-OF-SELECTION.
CREATE OBJECT ref1.
or INITIALIZATION
CREATE OBJECT ref1.
2009 Jun 22 2:18 PM
Hi,
Try
START-OF-SELECTION.
CREATE OBJECT ref1.
or INITIALIZATION
CREATE OBJECT ref1.
2009 Jun 22 2:22 PM
Or you an move your implementations to the end of the program.
REPORT ztest_classes.
*&---------------------------------------------------------------------*
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
METHODS: fun1.
DATA: var1.
ENDCLASS. "class1 DEFINITION
DATA: ref1 TYPE REF TO class1.
CREATE OBJECT ref1.
ref1->fun1( ).
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD fun1.
WRITE:/ 'Inside FUN1 of class1'.
ENDMETHOD. "fun1
ENDCLASS. "class1 IMPLEMENTATION
Regards,
Rich Heilman
2009 Jun 22 2:30 PM
Thank you Gary & Rich.
Both of your solutions have solved the problem. Could you please let me know the reason why start-of-selection has to be mentioned or why the implemention should be moved to the end of the code.
Regards,
Naga Sai Swapna
2009 Jun 22 2:39 PM
2009 Jun 22 2:29 PM
Hi,
Basically you should have some event such as START-OF-SELECTION after your class implementation.
Otherwise anything declared is considered as a part of the class and if it is not declared within the implementation you get this syntax error.
Regards,
Ankur Parab