메뉴 건너뛰기

SAP 한국 커뮤니티



constructor multiple instantiation 예

철죽1 2012.09.02 21:55 조회 수 : 11693

REPORT  zr_class_03.

*----------------------------------------------------------------------*

*       CLASS lcl_car DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_car DEFINITION.
  
PUBLIC SECTION
.
    
METHODS get_car EXPORTING ex_model TYPE
 string
                              ex_make 
TYPE
 string.
    
METHODS constructor IMPORTING im_model TYPE
 string
                                  im_make 
TYPE
 string.

  
PRIVATE SECTION
.
    
DATA: model TYPE
 string,
          make 
TYPE
 string.
    
METHODS set_car IMPORTING im_model TYPE
 string
                              im_make 
TYPE
 string.
ENDCLASS.                    "lcl_car DEFINITION



*----------------------------------------------------------------------*
*       CLASS lcl_car IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_car IMPLEMENTATION.
  
METHOD
 constructor.
    me->set_car( 
EXPORTING
 im_model = im_model
                           im_make = im_make ).
  
ENDMETHOD.                    "constructor

  
METHOD get_car.
    ex_model = me->model.
    ex_make = make.
  
ENDMETHOD.                    "get_car

  
METHOD set_car.
    me->model = im_model.
    me->make = im_make.
  
ENDMETHOD.                    "set_car

ENDCLASS.                    "lcl_car IMPLEMENTATION

START-
OF-SELECTION.
  
DATA: r_car TYPE REF TO
 lcl_car,
        r_tab 
TYPE TABLE OF REF TO
 lcl_car,
        gv_model 
TYPE
 string,
        gv_make 
TYPE
 string.

  
CREATE
 OBJECT r_car
    
EXPORTING

      im_model = 
'SM7'
      im_make  = 
'2009'.

  
APPEND r_car TO
 r_tab.

  
CREATE
 OBJECT r_car
    
EXPORTING

      im_model = 
'SM5'
      im_make  = 
'2010'.

  
APPEND r_car TO
 r_tab.

  
LOOP AT r_tab INTO
 r_car.
    r_car->get_car( 
IMPORTING
 ex_model = gv_model
                              ex_make = gv_make ).

    
WRITE
:/ gv_model, gv_make.
  
ENDLOOP.

번호 제목 글쓴이 날짜 조회 수
1284 IDOC 관련 [5] file 민상애비 2012.11.15 14212
1283 SAP Query [10] file 민상애비 2012.11.15 7689
1282 LSMW,CATT [8] file 민상애비 2012.11.14 12818
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 13086
1279 ABAP Tunning Guide [2] 민상애비 2012.11.14 15737
1278 ABAP Troubleshooting [4] file paran 2012.11.14 14606
1277 파일 첨부 - 한개씩 말고 다중으로 가능? [1] 연오랑 2012.10.24 12798
1276 gdb형식의 abap 강좌입니다. [6] tobypapa 2012.10.19 10990
1275 sap 튜닝 자료입니다. [44] file iop890mm 2012.10.10 12701
1274 POC 예 [9] 철죽1 2012.09.02 11117
1273 lock 예 [5] 철죽1 2012.09.02 13227
1272 tabstrip [5] 철죽1 2012.09.02 12159
1271 selection screen program [1] 철죽1 2012.09.02 5585
1270 method create 예 철죽1 2012.09.02 11647
1269 instance vs static 예 [1] 철죽1 2012.09.02 12622
» constructor multiple instantiation 예 철죽1 2012.09.02 11693
1267 casting 예 [1] 철죽1 2012.09.02 11483
1266 create object 예. [1] 철죽1 2012.09.02 12935
1265 shared objects 예제 file 철죽1 2012.09.02 5424