I found a solution here which I try to apply.
cl_salv_bs_runtime_info=>set(
EXPORTING
display = abap_false
metadata = abap_false
data = abap_true
).
SUBMIT ('RM07MLBS')
AND RETURN.
DATA: lt_outtab TYPE STANDARD TABLE OF alv_t_t2.
FIELD-SYMBOLS: <lt_outtab> like lt_outtab.
DATA lo_data TYPE REF TO data.
TRY.
" get data from SALV model"
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING
r_data = lo_data
).
ASSIGN lo_data->* to <lt_outtab>.
BREAK-POINT.
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
return.
Source: http://zevolving.com/2015/07/salv-table-22-get-data-directly-after-submit/
But this does not work. I get a type mismatch error in this line:
ASSIGN lo_data->* to <lt_outtab>.
What could be wrong?
Update: is there a way to do this generic? At runtime I don't know which report gets called. The above code is just an example.
Update2: My overall goal is to get the report in XML (or json) format.
I added dynamic table, line and component to your code for creating working example.
With the help of the answer of user mkysoft, this is the working solution, which exports the data in json format:
This helped me to get it done: https://blogs.sap.com/2011/07/07/gain-programmatic-access-to-data-of-sapgui-alv-reports/