*&---------------------------------------------------------------------*
*& Report ZTESTOO3
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTESTOO3.
*CLASS CLTEST DEFINITION.
* PUBLIC SECTION.
* CLASS-DATA:W_NUMBER TYPE I."实例属性
* METHODS:SET_VALUE IMPORTING W_I TYPE I,
* GET_VALUE EXPORTING W_NUM TYPE I.
*ENDCLASS.
*
*CLASS CLTEST IMPLEMENTATION.
* METHOD:SET_VALUE.
* W_NUMBER = W_I.
* ENDMETHOD.
* METHOD:GET_VALUE.
* W_NUM = W_NUMBER.
* ENDMETHOD.
*ENDCLASS.
CLASS SUB_CLASS DEFINITION INHERITING FROM ZCL_TEST_TONY3.
PUBLIC SECTION.
METHODS:SET_VALUE REDEFINITION.
ENDCLASS.
CLASS SUB_CLASS IMPLEMENTATION.
* METHOD ABC.
* MESSAGE '子类方法' TYPE 'I'.
* ENDMETHOD.
METHOD SET_VALUE.
MESSAGE 'ABC' TYPE 'I'.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA:W_RESULT TYPE I.
DATA:G_OBJ TYPE REF TO ZCL_TEST_TONY3."声明一个对象
DATA:G_OBJ2 TYPE REF TO ZCL_TEST_TONY3."声明一个对象
DATA:G_SUB_OBJ TYPE REF TO SUB_CLASS."声明一个对象
CREATE OBJECT G_OBJ."创建对象
CREATE OBJECT G_OBJ2."创建对象
CREATE OBJECT G_SUB_OBJ."创建对象
CALL METHOD G_OBJ->SET_VALUE
EXPORTING W_I = 7.
CALL METHOD G_SUB_OBJ->SET_VALUE
EXPORTING W_I = 0.
* CALL METHOD G_SUB_OBJ->ABC.
* CALL METHOD G_OBJ->GET_VALUE
* IMPORTING W_NUM = W_RESULT.
* CALL METHOD G_OBJ2->GET_VALUE
* IMPORTING W_NUM = W_RESULT.
WRITE G_OBJ->W_NUMBER.
WRITE G_SUB_OBJ->W_NUMBER.
阅读(2041) | 评论(0) | 转发(0) |