Because nobody wants to change another report but wants to use the reports output in his program , how to get output table of an ABAP report is a frequently asked question for ABAP’ers.
There are many ways to achieve this functionality, for example call ABAP report and get the output as internal table post gives a weak solution to the question as it does not return the table as structured. Actually EXPORT TO MEMORY and IMPORT FROM MEMORY commands are tailor-made solutions for this question. You should first think of implementing this commands if you take risk of changing called ABAP report.
However think a scenario where you are calling an SAP standard report which you do not want to intervene. This time you got stuck as both above alternatives fail due to the mentioned weak sides.
Finally as a clean solution you can expolit CL_SALV_BS_RUNTIME_INFO which is designed to reach ALV’s run time environment.
Following sample report implement this clean method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
*&---------------------------------------------------------------------* *& Report Z_SUBMIT *&---------------------------------------------------------------------* report z_submit. start-of-selection . field-symbols <lt_pay_data> type any table. data lr_pay_data type ref to data. cl_salv_bs_runtime_info=>set( exporting display = abap_false metadata = abap_false data = abap_true ). submit zya_background_output and return. try. cl_salv_bs_runtime_info=>get_data_ref( importing r_data = lr_pay_data ). assign lr_pay_data->* to <lt_pay_data>. catch cx_salv_bs_sc_runtime_info. message `Unable to retrieve ALV data` type 'E'. endtry. cl_salv_bs_runtime_info=>clear_all( ). |