具体操作不写
首先在屏幕上画好alv控件,命名:ZALV_CTR
DATA
:
alv_ctr TYPE REF TO cl_gui_custom_container , "ALV容器
alv_grid TYPE REF TO cl_gui_alv_grid . "ALV网格,用于显示
alv_ctr TYPE REF TO cl_gui_custom_container , "ALV容器
alv_grid TYPE REF TO cl_gui_alv_grid . "ALV网格,用于显示
初始化:
IF alv_grid IS INITIAL. "如果未初始化
CREATE OBJECT alv_ctr "容器
EXPORTING
container_name = 'ZALV_CTR'.
CREATE OBJECT alv_grid "ALV显示控制器
EXPORTING
i_parent = alv_ctr. "绑定容器和ALV显示
CREATE OBJECT alv_ctr "容器
EXPORTING
container_name = 'ZALV_CTR'.
CREATE OBJECT alv_grid "ALV显示控制器
EXPORTING
i_parent = alv_ctr. "绑定容器和ALV显示
ENDIF.
显示:
CALL
METHOD alv_grid
->set_table_for_first_display
EXPORTING
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
i_structure_name = 'SPFLI' "显示的参考结构
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = g_it_spfli "需要显示的数据内表
* it_fieldcatalog =
* it_sort =
* it_filter =
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* others = 4
.
IF sy -subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
EXPORTING
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
i_structure_name = 'SPFLI' "显示的参考结构
* is_variant =
* i_save =
* i_default = 'X'
* is_layout =
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
CHANGING
it_outtab = g_it_spfli "需要显示的数据内表
* it_fieldcatalog =
* it_sort =
* it_filter =
* EXCEPTIONS
* invalid_parameter_combination = 1
* program_error = 2
* too_many_lines = 3
* others = 4
.
IF sy -subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
刷新:
CALL
METHOD alv_grid
->refresh_table_display
* EXPORTING
* is_stable =
* i_soft_refresh =
* EXCEPTIONS
* finished = 1
* others = 2
.
IF sy -subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .
* EXPORTING
* is_stable =
* i_soft_refresh =
* EXCEPTIONS
* finished = 1
* others = 2
.
IF sy -subrc <> 0 .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF .