메뉴 건너뛰기

SAP 한국 커뮤니티



instance vs static 예

철죽1 2012.09.02 21:56 조회 수 : 12623

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.

번호 제목 글쓴이 날짜 조회 수
1284 IDOC 관련 [5] file 민상애비 2012.11.15 14214
1283 SAP Query [10] file 민상애비 2012.11.15 7689
1282 LSMW,CATT [8] file 민상애비 2012.11.14 12819
1281 05. IT_ABAP v4.6x Software Development Standards & Controls_EN Ver0.8_k file 민상애비 2012.11.14 14085
1280 Technical Guide-ABAP Tuning 기초 [5] file 민상애비 2012.11.14 13088
1279 ABAP Tunning Guide [2] 민상애비 2012.11.14 15737
1278 ABAP Troubleshooting [4] file paran 2012.11.14 14609
1277 파일 첨부 - 한개씩 말고 다중으로 가능? [1] 연오랑 2012.10.24 12803
1276 gdb형식의 abap 강좌입니다. [6] tobypapa 2012.10.19 10993
1275 sap 튜닝 자료입니다. [44] file iop890mm 2012.10.10 12709
1274 POC 예 [9] 철죽1 2012.09.02 11121
1273 lock 예 [5] 철죽1 2012.09.02 13228
1272 tabstrip [5] 철죽1 2012.09.02 12160
1271 selection screen program [1] 철죽1 2012.09.02 5585
1270 method create 예 철죽1 2012.09.02 11647
» instance vs static 예 [1] 철죽1 2012.09.02 12623
1268 constructor multiple instantiation 예 철죽1 2012.09.02 11694
1267 casting 예 [1] 철죽1 2012.09.02 11486
1266 create object 예. [1] 철죽1 2012.09.02 12935
1265 shared objects 예제 file 철죽1 2012.09.02 5424