1.
FORM disp_alv .
DATA l_repid LIKE sy-repid VALUE sy-repid.
DATA: l_grid_settings TYPE lvc_s_glay .
PERFORM frm_set_fieldcats.
gw_layout-zebra = 'X'.
gw_layout-sel_mode = 'X'.
* gw_layout-cwidth_opt = 'X'.
* gw_layout-box_fname = 'SEL'.
*
*
* lw_event-name = 'CALLER_EXIT'.
* lw_event-form = 'SET_LIST' ##CALLED .
* append lw_event to lt_event.
l_grid_settings-edt_cll_cb = 'X' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' ##FM_SUBRC_OK
EXPORTING
i_callback_program = l_repid
i_callback_pf_status_set = 'ALV_PF_STATUS' "这个ALV_PF_STATUS 对应的是form的名字,设置alv状态的
##CALLED
i_callback_user_command = 'ALV_USER_COMMAND' "这个ALV_USER_command 对应的也是form的名字
i_grid_settings = l_grid_settings
is_layout_lvc = gw_layout
it_fieldcat_lvc = gt_field
i_save = 'X'
"i_default = 'X'
TABLES
t_outtab = gt_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0 .
ENDIF.
ENDFORM.
2. 界面编辑文本没法自动更新时,
a. 可以点击enter,ALV function 会自动刷新
b. 在 i_callback_user_command 的方法里加入以下语句
DATA: l_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.
CALL METHOD l_grid->check_changed_data.
这样会将界面编辑后的字段自动更新掉