OO 技术实现简单的ALV显示
REPORT Z_ALV_ERIC.
data: ok_code type sy-ucomm,
save_ok like ok_code.
data wa_spfli type table of spfli.
select * into table wa_spfli from spfli.
data: wa_container type scrfname value 'ALV',
alv_grid type ref to cl_gui_alv_grid,
wa_custom_container TYPE ref to cl_gui_custom_container.
call SCREEN 1001.
*&---------------------------------------------------------------------*
*& Module STATUS_1001 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_1001 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
if wa_custom_container is initial.
create object wa_custom_container
EXPORTING container_name = wa_container.
create object alv_grid
EXPORTING i_parent = wa_custom_container.
call method alv_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SPFLI'
CHANGING it_outtab = wa_spfli.
endif.
ENDMODULE. " STATUS_1001 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1001 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_1001 INPUT.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'XT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_1001 INPUT