[SAP ABAP] 클래스(Class) 생성 및 구현

2013. 5. 27. 22:35SAP ERP System/ABAP 실습

 

 

이번시간에는 [SAP ABAP] Class 생성 및 구현을 해보도록 하겠습니다.

 

  *&---------------------------------------------------------------------*
*& Report  ZR_CLASS_01
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZR_CLASS_01.

*----------------------------------------------------------------------*
*       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 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.
  CREATE OBJECT r_car02.


  r_car01->set_carEXPORTING im_model 'SM7'
                                                   im_make '2009'  ).

  r_car01->get_carIMPORTING ex_model gv_model
                                                  ex_make gv_make
                                                  ex_count gv_count ).

  write:/ gv_model, gv_make, gv_count.

    r_car02->set_carEXPORTING im_model 'SM7'
                                                   im_make '2009'  ).

  r_car02->get_carIMPORTING ex_model gv_model
                                                  ex_make gv_make
                                                  ex_count gv_count ).

  write:/ gv_model, gv_make, gv_count.

 

 

이번시간에는 [SAP ABAP] Class 생성 및 구현을 해보았습니다.

1 2 3 4 5 6