ABAP 获取ALV报表中的数据

当程序中需要获取某张报表展示的ALV数据,又不想重新写一遍查询逻辑,则可以调用该报表,直接将报表的ALV内表的数据获取到,提高开发效率

"-----------------------------@斌将军-----------------------------
DATA:lo_data TYPE REF TO data, lt_select TYPE TABLE OF rsparams, ls_select TYPE rsparams. FIELD-SYMBOLS TYPE ANY TABLE. "初始设置 CALL METHOD cl_salv_bs_runtime_info=>set EXPORTING display = abap_false metadata = abap_false data = abap_true. "报表筛选条件 CLEAR ls_select. ls_select-selname = 'S_MONTH'. ls_select-sign = 'I'. ls_select-option = 'EQ'. ls_select-low = '202204'. *ls_select-high = ''. APPEND ls_select TO lt_select. *CLEAR ls_select. *ls_select-selname = 'S_KUNNR'. *ls_select-sign = 'I'. *ls_select-option = 'EQ'. *ls_select-low = '202204'. **ls_select-high = ''. *APPEND ls_select TO lt_select. "调用目标报表 SUBMIT zsd001 WITH SELECTION-TABLE lt_select "多选 * WITH p_year = i_year AND RETURN. TRY. "获取ALV显示数据 CALL METHOD cl_salv_bs_runtime_info=>get_data_ref IMPORTING r_data = lo_data. IF lo_data IS INITIAL. MESSAGE '无数据' TYPE 'S' DISPLAY LIKE 'E'. RETURN. ENDIF. ASSIGN lo_data->* TO . CATCH cx_salv_bs_sc_runtime_info. ENDTRY. IF IS NOT INITIAL. "填充报表数据到内表 MOVE-CORRESPONDING TO gt_alv. ENDIF. "清理 cl_salv_bs_runtime_info=>clear_all( ).
"-----------------------------@斌将军-----------------------------

你可能感兴趣的:(ABAP 获取ALV报表中的数据)