双击显示 ALV table 行详细信息?

Show ALV table row details on double click?

假设我有一个 table 客户,显示在 alv-grid 中,如下所示:

**BEFORE THIS: Set up parameters, SQL Select, Table etc.
CREATE OBJECT gr_alv_grid
    EXPORTING
        i_parent = cl_gui_custom_container=>default_screen
    EXCEPTIONS
        error_cntl_create = 1
        error_cntl_init = 2
        error_cntl_link = 3
        error_dp_create = 4
        others = 5.
   IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
   ENDIF.

gr_alv_grid->set_table_for_first_display(
    EXPORTING
        i_structure_name = 'ZDebcdstest'
    CHANGING
        it_outtab = lt_debis
    EXCEPTIONS
        invalid_parameter_combination = 1
        program_error = 2
        too_many_lines = 3
        others = 4
).
IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

我想要的是双击任何给定行并获得其中包含的对象的更详细概述的选项,例如在 SE16 中完成的.我已经设置了一个事件处理程序来监听双击,这很有效,但我还没有弄清楚如何连续获取所有相关数据并详细显示所选对象。

非常感谢任何帮助。

这是如何使其工作的原始示例“就像在 SE16 中所做的那样”

  METHOD handle_double_click.
    DATA: ls_sflight LIKE LINE OF gt_sflight,
          ls_layout  TYPE lvc_s_layo.

    DATA: lt_fieldcatalog TYPE lvc_t_fcat,
          ls_fieldcatalog TYPE lvc_s_fcat.

    DATA: details_outtab TYPE lvc_t_detm,
          ls_detail      TYPE lvc_s_detm,
          lt_detail_tab  TYPE lvc_t_deta,
          ls_detail_tab  TYPE lvc_s_deta.

    READ TABLE gt_sflight INDEX e_row-index INTO ls_sflight.

    ls_fieldcatalog-fieldname = 'COLUMNTEXT'.
    ls_fieldcatalog-ref_table = 'LVC_S_DETA'.
    ls_fieldcatalog-key       = 'X'.
    ls_fieldcatalog-seltext   = 'Field'.
    ls_fieldcatalog-outputlen = 30.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.

    CLEAR ls_fieldcatalog.
    ls_fieldcatalog-fieldname = 'VALUE'.
    ls_fieldcatalog-ref_table = 'LVC_S_DETA'.
    ls_fieldcatalog-seltext   = 'Field value'.
    ls_fieldcatalog-outputlen = 20.
    APPEND ls_fieldcatalog TO lt_fieldcatalog.

    ls_layout-no_toolbar = 'X'.

    LOOP AT gt_fieldcat ASSIGNING FIELD-SYMBOL(<field>).
      ls_detail_tab-columntext = <field>-scrtext_l.
      ASSIGN COMPONENT sy-tabix OF STRUCTURE ls_sflight TO FIELD-SYMBOL(<col>).
      ls_detail_tab-value = <col>.
      APPEND ls_detail_tab TO lt_detail_tab.
    ENDLOOP.
    ls_detail-detailtab = lt_detail_tab.
    APPEND ls_detail TO details_outtab.

    CALL FUNCTION 'LVC_ITEM_DETAIL'
      EXPORTING
        i_title               = 'Row details'
        it_fieldcatalog       = lt_fieldcatalog
        is_layout             = ls_layout
      TABLES
        t_outtab              = details_outtab.

  ENDMETHOD.                           "handle_double_click

在上面的片段中

gt_sflight - main table 你想从

捕获行详细信息

gt_fieldcat - 此 table 的字段目录必须在触发事件

之前填充

如果您不知道如何将此方法应用于您的 ALV,请搜索 some tutorial 关于事件实现。