【SAP】ABAP——获取ALV显示后过滤的数据

背景:报表ALV显示数据后,需要将过滤后的数据推送到另一个系统。

实现:通过类CL_GUI_ALV_GRID的方法GET_FILTERED_ENTRIES获取被过滤掉的内表数据行号,筛选后的ALV内表数据=内表数据-被过滤掉的内表数据。

DATA: lo_grid  TYPE REF TO cl_gui_alv_grid,
        filt_table TYPE lvc_t_fidx,
        l_filt_table TYPE int4 .

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = lo_grid.

  CALL METHOD lo_grid->get_filtered_entries
    IMPORTING
      et_filtered_entries = filt_table."被过滤的内表数据行

  l_ucomm = r_ucomm.
  CASE l_ucomm.
    WHEN '&SEND'."推送至其他系统
      LOOP AT it_out.
        READ TABLE filt_table INTO l_filt_table
             WITH KEY table_line = sy-tabix.“看该行是否在被过滤的内表行中
        IF sy-subrc <> 0.
          ls_send-ebeln = it_out-ebeln.
          ls_send-ekorg = it_out-ekorg.
          ls_send-matnr = it_out-matnr.
          ls_send-txz01 = it_out-txz01.
          ls_send-belnr = it_out-belnr.
          APPEND ls_send TO lt_send.
          CLEAR ls_send.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'Z_FI_SEND'  "推送至其他系统
        IMPORTING
          es_return       = ls_return
        TABLES
          it_send         = lt_send.

      MESSAGE ls_return-message TYPE ls_return-type.
    WHEN OTHERS.
  ENDCASE.

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页