我正在使用 class 创建一个 ALV 输出网格cl_gui_alv_grid
。通过使用 fieldcatalog 的相应记录,将输出表的其中一列定义为复选框:
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
对于包含复选框的列的所有记录,它们都设置为未选中。我的问题是我可以实现什么逻辑,以便对于某些行,在显示 ALV 时将复选框设置为选中状态。
如果您想根据 alv 网格中最初显示的数据设置复选框,只需在条件匹配时使用 abap_true (='X') 填写您的 outtab 复选框字段。如果您不使用 fieldcatalog 的复选框参数,您只会看到“X”表示已选中,“”表示未选中。
如果要根据用户输入设置复选框,在他们编辑 alv 网格中的某些字段后,使用以下 alv 网格事件来更改 outtab:
METHODS:
handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished FOR EVENT data_changed_finished OF cl_gui_alv_grid, "executed only if no errors, outtab holds changed data
当我不得不处理这些事件时,我还发现了一些我发表的评论
*&---------------------------------------------------------------------*
*& Method handle_data_changed
*&---------------------------------------------------------------------*
* raised when at least one cell is modified in the ALV
* - modified entries are not stored in gt_outtab yet, but er_data_changed object
* - mt_good_cells holds every changed field thats valid according to type declaration
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Method handle_data_changed_finished
*&---------------------------------------------------------------------*
* - raised when data validation is valid
* - NOW outtab holds valid changed data
*----------------------------------------------------------------------*