【ABAP】ALV刷新显示及双击ALV跳转事务码的方法

ALV刷新显示的方法如下

 call method ref1->check_changed_data .     "检查alv变更
  call method ref1->refresh_table_display .  "刷新显示

刷新按钮

when '&NTE'.
      rs_selfield-refresh = 'X'.    " REFESH ALV

如何只选中筛选后的全选或取消全选,方法如下。lt_filter表中就是被筛选后的数据,后续通过不同操作取得你想要的数据。

when '&AL'.
      call method ref1->get_filtered_entries
        importing
          et_filtered_entries = lt_filter.    "lt_filter表中就是被筛选后的数据,后续通过不同操作取得你想要的数据。

      loop at itab.
        lv_tabix = sy-tabix.
        read table lt_filter with key table_line = lv_tabix transporting no fields.
        if sy-subrc ne 0.
          itab-box = 'X'.
          modify itab.
          clear itab.
        endif.
      endloop.
      call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        importing
          e_grid = ref1.
      call method ref1->check_changed_data.
      rs_selfield-refresh = 'X'.

    when '&SA'.
      call method ref1->get_filtered_entries
        importing
          et_filtered_entries = lt_filter.  "lt_filter表中就是被筛选后的数据,后续通过不同操作取得你想要的数据。

      loop at itab.
        lv_tabix = sy-tabix.
        read table lt_filter with key table_line = lv_tabix transporting no fields.
        if sy-subrc ne 0.
          itab-box = ''.
          modify itab.
          clear itab.
        endif.
      endloop.
      call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        importing
          e_grid = ref1.
      call method ref1->check_changed_data.
      rs_selfield-refresh = 'X'.

双击跳转事务码的功能,这里我需要跳转到具体凭证,方法如下。&IC1为双击ALV某一格。用set parameter id 填充事务码必要字段信息, call transaction 跳转事务码到skip first screen。

 when '&IC1'.
* 获取当前ALV所在行数据
*      call method cl_gui_cfw=>dispatch.
      data:belnr like bseg-belnr.
      read table itab index rs_selfield-tabindex.
      call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
        exporting
          input  = itab-belnr
        importing
          output = belnr.

      set parameter id: 'BLN' field belnr.
      set parameter id: 'BUKRS' field itab-bukrs.
      call transaction 'FB03' and skip first screen.

你可能感兴趣的:(sap,abap,sap,abap)