넷위버 7.0 트라이버젼으로 실습하는데 아래의 문제가 생겨 질문을 드립니다.
1. 결과를 확인하니 아래의 메세지가 나옵니다.
method "set(exporting" is unknown or protected or private.
아무리 뒤져봐도 뭐가 잘못됐지 알수가 없네요.
*&---------------------------------------------------------------------*
*& Report Z17_003
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z17_003.
*----------------------------------------------------------------------*
* CLASS counter DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS counter DEFINITION.
PUBLIC SECTION.
METHODS: set IMPORTING set_value TYPE i,
increment,
get EXPORTING get_value TYPE i.
DATA count TYPE i.
ENDCLASS. "counter DEFINITION
*----------------------------------------------------------------------*
* CLASS counter IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD. "set
METHOD increment.
ADD 1 TO count.
ENDMETHOD. "increment
METHOD get.
get_value = count.
ENDMETHOD. "get
ENDCLASS. "counter IMPLEMENTATION
DATA: cref1 TYPE REF TO counter,
l_imp TYPE I.
START-OF-SELECTION.
CREATE OBJECT cref1.
CALL METHOD cref1->set(exporting set_value = 3).
WRITE: / 'set method:', cref1->count.
CALL METHOD cref1->increment.
CALL METHOD cref1->get(importing get_value = l_imp).
WRITE: / 'get method:', l_imp.
2. 실행을 하니 아래의 메세지가 나옵니다.
method "set" is not declared or inherited in class "counter"....
e아밥 홈페이지에 있는 소스를 그대로 이용한건데 위 메시지가 나오네요.
뭐가 잘못됐나요?
REPORT z17_004.
CLASS counter DEFINITION.
PRIVATE SECTION.
* PROTECTED SECTION.
DATA count TYPE i.
ENDCLASS.
CLASS counter2 DEFINITION INHERITING FROM counter.
PUBLIC SECTION.
METHODS: set IMPORTING set_value type i,
increment,
get EXPORTING get_value type i.
ENDCLASS.
CLASS counter IMPLEMENTATION.
METHOD set.
count = set_value.
ENDMETHOD.
METHOD increment.
ADD 1 TO count.
ENDMETHOD.
METHOD get.
get_value = count.
ENDMETHOD.
ENDCLASS.
DATA : CREF1 TYPE REF TO COUNTER2,
L_imp TYPE I.
START-OF-SELECTION.
CREATE OBJECT CREF1.
CALL METHOD CREF1->SET( exporting set_value = 3 ).
CALL METHOD CREF1->increment.
CALL METHOD CREF1->GET( IMPORTING get_value = l_imp ).
WRITE : / 'GET METHOD :' , l_imp.
위 내용에 대해 자세한 조언부탁합니다.
추석 마지막입니다. 잘 보내세요.^^
다음 소스를 이용해서,
public, private, protected 속성을 변경해 가면서 테스트 해보세요
http://e-abap.servebbs.net/zb/bbs/view.php?id=SOURCE&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&keyword=17_003&select_arrange=headnum&desc=asc&no=102
http://e-abap.servebbs.net/zb/bbs/view.php?id=SOURCE&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&keyword=17_004&select_arrange=headnum&desc=asc&no=103