我们在程序中定义的类只能在本程序中使用,如果我们需要该类能被所有程序调用,那么就需要使用全局类。
举例:程序中类:lcl_report,转换成全局类:zcl_report
1、程序代码 REPORT y001.
CLASS lcl_report DEFINITION. PUBLIC SECTION. METHODS:select_data, write_data. PRIVATE SECTION. DATA:lt_t100 TYPE TABLE OF t100. ENDCLASS. CLASS lcl_report IMPLEMENTATION. METHOD select_data. SELECT * INTO TABLE lt_t100 UP TO 10 ROWS FROM t100 WHERE sprsl = sy-langu. ENDMETHOD. METHOD write_data. FIELD-SYMBOLS: <fs_t100> TYPE t100. LOOP AT lt_t100 ASSIGNING <fs_t100>. WRITE:/ <fs_t100>-arbgb, <fs_t100>-text. ENDLOOP. ENDMETHOD. ENDCLASS.
START-OF-SELECTION. DATA:lo_main TYPE REF TO lcl_report.
CREATE OBJECT lo_main. lo_main->select_data( ). lo_main->write_data( ).
2、T-code:SE24
3、选中需要转换的类,可以重新命名,点击导入
4、激活全局类