REPORT zr_class_02.
*----------------------------------------------------------------------*
* CLASS lcl_car DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_car DEFINITION.
PUBLIC SECTION.
METHODS set_car IMPORTING im_model TYPE string
im_make TYPE string.
METHODS get_car EXPORTING ex_model TYPE string
ex_make TYPE string
ex_count TYPE i.
PRIVATE SECTION.
DATA: model TYPE string,
make TYPE string.
CLASS-DATA count TYPE i.
ENDCLASS. "lcl_car DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_car IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_car IMPLEMENTATION.
METHOD set_car.
model = im_model.
make = im_make.
count = 1 + count.
ENDMETHOD. "set_car
METHOD get_car.
ex_model = model.
ex_make = make.
ex_count = count.
ENDMETHOD. "get_car
ENDCLASS. "lcl_car IMPLEMENTATION
START-OF-SELECTION.
DATA: r_car01 TYPE REF TO lcl_car,
r_car02 TYPE REF TO lcl_car.
DATA: gv_model TYPE string,
gv_make TYPE string,
gv_count TYPE i.
CREATE OBJECT r_car01.
r_car01->set_car( EXPORTING im_model = 'SM7'
im_make = '2009' ).
r_car01->get_car( IMPORTING ex_model = gv_model
ex_make = gv_make
ex_count = gv_count ).
WRITE:/ gv_model, gv_make, gv_count.
CREATE OBJECT r_car02.
r_car02->set_car( EXPORTING im_model = 'SM5'
im_make = '2010' ).
r_car02->get_car( IMPORTING ex_model = gv_model
ex_make = gv_make
ex_count = gv_count ).
WRITE:/ gv_model, gv_make, gv_count.
r_car01->get_car( IMPORTING ex_model = gv_model
ex_make = gv_make
ex_count = gv_count ).
WRITE:/ gv_model, gv_make, gv_count.
local class 내에 class-data 로 선언된 work area 는 class 의 All instances ( crete 될때 마다 1개의 instances 개 생성됨)에 영향을 줍니다.
class-data = static 입니다. 참고 하세요..