目前在做关于可编辑ALV的一个东西. 发现一个奇怪的问题,
修改CELL可编辑的代码在ALV的user_command事件中不起作用, DEBUG时发现代码也运行了,但不起作用, 而在屏幕的PBO中调用时可以起作用.
请教一下.这两种处理有什么区别? 在什么情况下使用?
下面是修改ALV可编辑的代码.
FORM modify_alv .
DATA: lt_selcells TYPE lvc_t_cell,
l_lines TYPE i.
FIELD-SYMBOLS: <lw_result> TYPE ty_result,
<lw_style> TYPE lvc_s_styl,
<lw_cell> TYPE lvc_s_cell.
DATA: lw_style TYPE lvc_s_styl.
CALL METHOD grf_grid->get_selected_cells
IMPORTING
et_cell = lt_selcells.
DESCRIBE TABLE lt_selcells LINES l_lines.
IF l_lines > 1.
MESSAGE 'Please select one cell to be modified.' TYPE 'W'.
RETURN.
ENDIF.
READ TABLE lt_selcells ASSIGNING <lw_cell>
INDEX 1.
CHECK sy-subrc = 0.
READ TABLE gt_result ASSIGNING <lw_result>
INDEX <lw_cell>-row_id-index.
CHECK sy-subrc = 0.
READ TABLE <lw_result>-style ASSIGNING <lw_style>
WITH KEY fieldname = <lw_cell>-col_id-fieldname.
IF sy-subrc <> 0.
lw_style-fieldname = <lw_cell>-col_id-fieldname.
lw_style-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT lw_style INTO TABLE <lw_result>-style. " sorted table, NO append statement.
ELSE.
<lw_style>-style = cl_gui_alv_grid=>mc_style_enabled.
ENDIF.
CALL METHOD grf_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. " modify_alv