我正在开发一个显示和可编辑ALV的报告。
我设置了pf-status,添加一个"过程"按钮。按下此按钮时,应检索用户在ALV中引入的内容然后处理。
这就是我的构建方式:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid "program name
i_callback_user_command = 'USER_COMMAND' "user command subroutine name
i_callback_pf_status_set = 'SUB_PF_STATUS'
it_fieldcat = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_input
EXCEPTIONS
program_error = 1
OTHERS = 2.
但是,我这样做的方式是空的。我怎么解决这个问题?
下面我有"进程"的代码段。
IF r_ucomm EQ '&PROC'.
LOOP AT it_input INTO ls_input.
PERFORM process_data USING ls_input.
ENDLOOP.
ENDIF.
获取ALV网格实例后运行其方法'check_changed_data'类似于下面的示例。
DATA lo_grid TYPE REF TO cl_gui_alv_grid.
IF r_ucomm EQ '&PROC'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
IF lo_grid IS NOT INITIAL.
lo_grid->check_changed_data( ).
ENDIF.
LOOP AT it_input INTO ls_input.
PERFORM process_data USING ls_input.
ENDLOOP.
ENDIF.
您可以直接创建ALV网格,而无需使用'reuse_alv_grid_display'的功能模块'set_table_for_first_display'。
DATA go_grid TYPE REF TO cl_gui_alv_grid.
CREATE OBJECT go_grid
EXPORTING
i_parent = cl_gui_custom_container=>default_screen.
go_grid->set_table_for_first_display(
CHANGING
it_outtab = it_input
it_fieldcatalog = it_fieldcat ).
...
IF r_ucomm EQ '&PROC'.
go_grid->check_changed_data( ).
LOOP AT it_input INTO ls_input.
PERFORM process_data USING ls_input.
ENDLOOP.
ENDIF.
请删除行 refresh IT_Input。这是删除IT_INPUT的内容,因此检索为空。您可以使用以下代码,而无需刷新IT_INPUT
IF r_ucomm EQ '&PROC'.
LOOP AT it_input INTO ls_input.
PERFORM process_data USING ls_input.
ENDLOOP.
ENDIF.