项目上有时候会遇到一些报表开发,可能时基于MB51的凭证查询后处理,或基于库存清单进行操作。这种需求其实在FS和开发上是都可以简化的,直接调用标准的报表数据进行加工,后续方案的调整等等对功能影响较小。
调用代码模板
if IV_SELECTION_SET_VARIANT is INITIAL.SUBMIT (IV_REPORT_NAME)WITH SELECTION-TABLE selection_tableAND RETURN.
ELSE.SUBMIT (IV_REPORT_NAME)WITH SELECTION-TABLE selection_tableUSING SELECTION-SET IV_SELECTION_SET_VARIANTAND RETURN.
endif.
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.
FIELD-SYMBOLS <lt_data_line> TYPE ANY TABLE.
DATA lr_data TYPE REF TO data.
DATA lr_data_line TYPE REF TO data.
DATA lr_data_descr TYPE REF TO cl_abap_datadescr.
DATA lr_data_line_descr TYPE REF TO cl_abap_datadescr.
cl_salv_bs_runtime_info=>get_data_ref(IMPORTING r_data_descr = lr_data_descrr_data_line_descr = lr_data_line_descr ).
IF lr_data_descr IS NOT BOUND.ev_result_json = '[]'.EXIT.
ENDIF.
代码示例:
TABLES:EKKO,EKPO.
SELECT-OPTIONS:
S_LIFNR FOR EKKO-LIFNR,
S_EKORG FOR EKKO-EKORG,
S_EKGRP FOR EKKO-EKGRP,
S_MATNR FOR EKPO-MATNR,
S_EBELN FOR EKPO-EBELN.FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.
FIELD-SYMBOLS <lt_data_line> TYPE ANY TABLE.DATA lr_data TYPE REF TO data.
DATA lr_data_line TYPE REF TO data.
DATA lr_data_descr TYPE REF TO cl_abap_datadescr.
DATA lr_data_line_descr TYPE REF TO cl_abap_datadescr.CL_SALV_BS_RUNTIME_INFO=>SET( EXPORTING DISPLAY = ABAP_FALSE METADATA = ABAP_FALSE DATA = ABAP_TRUE ).SUBMIT RM07MSAL
WITH LIFNR IN S_LIFNR "radiobutton 传参要用‘’
WITH EKORG IN S_EKORG
WITH EKGRP IN S_EKGRP
WITH MATNR IN S_MATNR
WITH EBELN IN S_EBELN
WITH FINAL = 'X'
WITH ALV_DEF = ''
WITH ZERO = ''
EXPORTING LIST TO MEMORY AND RETURN.TRY.cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data_descr = lr_data_descr
r_data_line_descr = lr_data_line_descr ).CREATE DATA lr_data TYPE HANDLE lr_data_descr.
CREATE DATA lr_data_line TYPE HANDLE lr_data_line_descr.ASSIGN lr_data->* TO <lt_data>.
ASSIGN lr_data_line->* TO <lt_data_line>.cl_salv_bs_runtime_info=>get_data(
IMPORTING
t_data = <lt_data>
t_data_line = <lt_data_line>
).CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `无数据` TYPE 'E'.ENDTRY.cl_salv_bs_runtime_info=>clear_all( ).