有时候写接口程序需要获取自开发报表或标准报表的ALV数据用于外发,这里以获取标准Tcode:MB52物料库存报表数据为例:
DATA: ls_data TYPE REF TO data.
FIELD-SYMBOLS: <lt_data> TYPE ANY TABLE,
<ls_data> TYPE data.
cl_salv_bs_runtime_info=>set(
display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT rm07mlbs WITH werks IN rt_werks
WITH pa_sond = ''
WITH nozero = 'X'
WITH pa_flt = 'X'
AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = ls_data ).
ASSIGN ls_data->* TO <lt_data>.
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
cl_salv_bs_runtime_info=>clear_error( ).
IF <lt_data> IS ASSIGNED.
LOOP AT <lt_data> ASSIGNING <ls_data>.
MOVE-CORRESPONDING <ls_data> TO ls_yfkdata.
APPEND ls_yfkdata TO lt_yfkdata.
CLEAR ls_yfkdata.
ENDLOOP.
ENDIF.
网友评论