ABAP OO [2] - Strtic attribute

*-----------------------------------------------------------------------
* Company XXX Company Limited
*
* Report Name: ZZW_ABAPOO_004
*
* Author: Lilo.Zhu
*
* Date: 2008.01.30
*-----------------------------------------------------------------------
* Description:
* =============
*
*-----------------------------------------------------------------------
* Change History:
* ===============
* Task# Date By Description
* XXX 2008.01.30 Lilo Initial Implementation
* Transport Request : XXXX
*----------------------------------------------------------------------

REPORT ZZW_ABAPOO_004 .

*----Class Definition----
CLASS LCL_COUNT DEFINITION.
PUBLIC SECTION.
CLASS-DATA LINT_STATIC TYPE I.
METHODS:
SET_OBJ_VALUE
IMPORTING VALUE(I_OBJ_VALUE) TYPE I,
SHOW_RESULT.
PRIVATE SECTION.
DATA LINT_OBJ_VALUE TYPE I.
CLASS-DATA LINT_COUNT TYPE I.
METHODS:
GET_OBJ_VALUE
EXPORTING VALUE(E_OBJ_VALUE) TYPE I.
ENDCLASS.

*----Class Implementations----
CLASS LCL_COUNT IMPLEMENTATION.
METHOD SET_OBJ_VALUE.
LINT_OBJ_VALUE = I_OBJ_VALUE.
ENDMETHOD.

METHOD GET_OBJ_VALUE.
E_OBJ_VALUE = LINT_OBJ_VALUE.
ENDMETHOD.

METHOD SHOW_RESULT.
CALL METHOD ME->GET_OBJ_VALUE
IMPORTING E_OBJ_VALUE = LINT_COUNT.
LINT_STATIC = LINT_COUNT.
ENDMETHOD.
ENDCLASS.

*------Main program------
DATA: VAL TYPE I,
LOBJ_COUNT TYPE REF TO LCL_COUNT.

START-OF-SELECTION.
CREATE OBJECT LOBJ_COUNT.
VAL = 10.

CALL METHOD LOBJ_COUNT->SET_OBJ_VALUE
EXPORTING I_OBJ_VALUE = VAL.


CALL METHOD LOBJ_COUNT->SHOW_RESULT.

* The Static attribute(not instanct) of call can be accessed directly
* via => symbol
*
WRITE: LCL_COUNT=>LINT_STATIC.

你可能感兴趣的:(OO)