본문 바로가기

SAP/ABAP

[ABAP] REPORT ZHANA01_04. Global Class 의 Attribute 및 Method 사용 예제

*&---------------------------------------------------------------------*
*& Report  ZHANA01_04
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zhana01_04.

DATA: r_st1 TYPE REF TO zcl_stu01,
      r_itab TYPE TABLE OF REF TO zcl_stu01,
      gv_name(10),
      gv_no(10),
      input_name(10).

*SELECT-OPTIONS so_name FOR input_name.

START-OF-SELECTION.

  CREATE OBJECT r_st1
    EXPORTING
*     im_name = input_name.
      im_name = 'Americano'.
  APPEND r_st1 TO r_itab.

  CREATE OBJECT r_st1
    EXPORTING
      im_name = 'min'.
  APPEND r_st1 TO r_itab.

  CREATE OBJECT r_st1
    EXPORTING
      im_name = '9to6'.
  APPEND r_st1 TO r_itab.

  LOOP AT r_itab INTO r_st1.
    CALL METHOD r_st1->get_info
      IMPORTING
        ex_name = gv_name
        ex_no   = gv_no.
    WRITE:/ gv_name, gv_no.
  ENDLOOP.

  WRITE:/ zcl_stu01=>gv_count.