*&---------------------------------------------------------------------* *& Report Y_JAMES_OO_DAY1 *& *&---------------------------------------------------------------------* *& *&just show you basic for OO(动态调用方法) *&---------------------------------------------------------------------* REPORT Y_JAMES_OO_DAY1. *------类的定义------------ CLASS C1 DEFINITION. PUBLIC SECTION. DATA: gt_itab TYPE TABLE OF sflight, gs_str TYPE sflight. METHODS:get_data, wri_data. ENDCLASS. " cl definition *------类的实例------------ CLASS c1 IMPLEMENTATION . METHOD: get_data. select * INTO TABLE gt_itab FROM sflight UP TO 5 ROWS. ENDMETHOD. " get_data METHOD: wri_data. LOOP AT gt_itab INTO gs_str. WRITE:/ gs_str-carrid, gs_str-connid. ENDLOOP. ENDMETHOD. " wri_data ENDCLASS. DATA go_oref TYPE REF TO c1. DATA gv_mth TYPE string. FIELD-SYMBOLS <fs> TYPE ANY. START-OF-SELECTION. CREATE OBJECT go_oref. gv_mth = 'GET_DATA'. * CALL METHOD go_oref->get_data. CALL METHOD GO_OREF->(gv_mth). CLEAR: gv_mth. gv_mth = 'WRI_DATA'. CALL METHOD GO_OREF->(gv_mth).