在用户输入后读取 ALV 更改? [英] Read ALV changes after user input?

查看:30
本文介绍了在用户输入后读取 ALV 更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份报告,它通过 ALV 网格输出我的内部表的数据.输出本身包含一些信息和每行的两个复选框.如有必要,用户可以选中这些框,现在我需要重新阅读表格以了解选中了哪些框.之后将根据两个框中的哪一个被选中对相应的行进行不同的处理.

I've got a report which outputs the data of my internal table via an ALV grid. The output itself consists of some information and two check boxes for each row. The user can check these boxes if necessary and now I need to read the table back in order to know what boxes were checked. The corresponding rows will be processed differently afterwards depending on which of the two boxes got checked.

我已经尝试过方法 get_actual_view,我不知道如何使用正确的方法和方法 get_selected_rows,它似乎获得了所选行的索引用户,而不是其内容.

I already tried the method get_actual_view, which I don't know how to use correct and the method get_selected_rows, which seems to get the index of the row selected by the user, but not its contents.

在用户选中复选框(然后按下按钮继续,这将触发报告中的编码以读取数据、处理数据并将其写回到网格中)后,我如何读取表格?

How can I read the table back after the user checked the boxes (and press a button to continue, which would trigger the coding in the report to read the data, process it and write it back into the grid)?

推荐答案

需要调用CL_GUI_ALV_GRID的方法CHECK_CHANGED_DATA来调用从 ALV 网格到内部表的输入(它适用于 ALV 中的所有类型的输入字段,即不限于复选框).

You need to call the method CHECK_CHANGED_DATA of CL_GUI_ALV_GRID to transfer the inputs from the ALV grid to the internal table (it works for all kinds of input fields in the ALV, i.e. not limited to checkboxes).

最小示例(在CHECK_CHANGED_DATA之前/之后添加一个断点,运行程序,编辑一些数据,例如吸烟者复选框,并查看输入如何反映到内部表中;注意:如果演示表 SBOOK 为空,则运行程序 SAPBC_DATA_GENERATOR) - 它使用 ABAP 7.40 和 + 编译:

Minimal example (add a break-point before/after CHECK_CHANGED_DATA, run the program, edit some data, for instance the smoker checkbox, and see how the input is reflected into the internal table; NB: if the demo table SBOOK is empty, run the program SAPBC_DATA_GENERATOR) - it compiles with ABAP 7.40 and + :

REPORT.
DATA go_alv TYPE REF TO cl_gui_alv_grid.
DATA gt_sbook TYPE TABLE OF sbook.

PARAMETERS dummy.

AT SELECTION-SCREEN OUTPUT.
  DATA: lt_fcat TYPE lvc_t_fcat,
        ls_fcat TYPE lvc_s_fcat.
  IF go_alv IS NOT BOUND.
    CREATE OBJECT go_alv
      EXPORTING
        i_parent = cl_gui_container=>screen0.
    SELECT * FROM sbook UP TO 100 ROWS INTO TABLE gt_sbook.
    lt_fcat = CORRESPONDING #( CAST cl_abap_structdescr(
          cl_abap_structdescr=>describe_by_name( 'SBOOK' ) )->get_ddic_field_list( ) ).
    ls_fcat-checkbox = abap_true.
    MODIFY lt_fcat FROM ls_fcat TRANSPORTING checkbox WHERE fieldname = 'SMOKER'.
    go_alv->set_table_for_first_display(
        EXPORTING
          is_layout        = VALUE #( edit = 'X' )
        CHANGING
          it_fieldcatalog  = lt_fcat
          it_outtab        = gt_sbook ).
  ENDIF.

AT SELECTION-SCREEN ON EXIT-COMMAND.
  go_alv->check_changed_data( ). " <=== transfer screen data to GT_SBOOK
  go_alv->free( ).

这篇关于在用户输入后读取 ALV 更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆