The goal is to use class cl_salv_bs_runtime_info
to read the ALV data from the report and create my own ALV afterwards.
The original report is creating an ALV:
The code to capture the ALV data is the following: (This is standard code that I have used with many ALV reports).
REPORT zhgirm06eps0.
FIELD-SYMBOLS <lt_data> TYPE ANY TABLE.
DATA lr_data TYPE REF TO data.
cl_salv_bs_runtime_info=>set(
EXPORTING display = abap_false
metadata = abap_false
data = abap_true ).
SUBMIT RM06EPS0 AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = lr_data ).
ASSIGN lr_data->* TO <lt_data>.
CATCH cx_salv_bs_sc_runtime_info.
MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
LOOP AT <lt_data> ASSIGNING FIELD-SYMBOL(<line>).
...
ENDLOOP.
After debugging the standard code I found out that everything should work just fine. the standard program is getting the data and also runs REUSE_ALV_GRID_DISPLAY
correctly.
BUT right after the ALV grid code there is a condition that creates the problem.
Standard code for the ALV in program FM06IF03
:
WHILE l_leave_sw IS INITIAL.
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
...
IF ls_exit_caused_by_user = 'X' OR "1094328
sy-batch = 'X' OR sy-binpt = 'X'.
l_leave_sw = 'X'.
ENDIF.
ENDWHILE.
As you can see the whole section is in a WHILE
loop. This while loop DOES NOT exit when using the SUBMIT
. The reason is that the variable l_leave_sw
never becomes true.
When you run the report normally everything works fine and the ALV is displayed.
I tried to set sy-batch
or sy-binpt
to true in my code but it was unsuccessful.
Any ideas on how to make it work?
We need to replace the
SUBMIT
withCALL TRANSACTION
withUSING bdc_tab
option.This way, the variable
sy-binpt
will be set to 'X' and the report should exit correctly without an endless loop.Final Code after just replacing submit: