cancel
Showing results for 
Search instead for 
Did you mean: 

Get ALV data in background ( cl_salv_bs_runtime_info )

jorg_vdst
Explorer
7,747

Hello,

We have an ABAP report with complex business logic and we would like to get the data from the program into SAP BW.

I managed to create an extractor based on a ABAP function module that calls the program and using cl_salv_bs_runtime_info retrieves the data without having to do any changes to the source program, which is perfect.

Unfortunately, I didn't consider that BW will create a background job and this results in the following error:

Control Framework: Fatal error - GUI cannot be reached

Is there a way to get the ALV data in background anyway? Preferably, without having to change the called program?

I'm a BW developer and not very experienced with output to GUI and any help is greatly appreciated.

Below my code.

* prepare
      cl_salv_bs_runtime_info=>set(
        EXPORTING display  = abap_false
                  metadata = abap_false
                  data     = abap_true ).


* Call program
      SUBMIT zmm_rapport_ma USING SELECTION-SET 'ZBW_MM28' AND RETURN.


* Get ALV data
      TRY.
          cl_salv_bs_runtime_info=>get_data_ref(
            IMPORTING r_data = lr_data ).
          ASSIGN lr_data->* TO <fs_data>.
        CATCH cx_salv_bs_sc_runtime_info.
          MESSAGE `Unable to retrieve ALV data` TYPE 'E'.
      ENDTRY.


      IF <fs_data>[] IS ASSIGNED.
        lt_mm[] = <fs_data>[].
      ENDIF.


      cl_salv_bs_runtime_info=>clear_all( ).

Accepted Solutions (0)

Answers (3)

Answers (3)

ThorstenHoefer
Active Contributor
0 Kudos

Hi,

consider to use the class CL_SALV_TABLE.

If you use the parameter LIST_DISPLAY in the factory function, the output is printed to the spool in background mode.

Hopefully this will help you for your requirements?

Best Regards

Thorsten

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe it's a custom program. So, you have to instantiate the ALV only if it's running in foreground mode.

if sy-batch eq abap_false.
"Instanciate ALV.
Endif.

If you do so then it will not go into dump.

Now second point is, how to get the data from the submit program. You can do it using either export ITAB to memory or using a static attribute of class to export it, then you have to import it in the function module.

Thanks,

Gourab

jorg_vdst
Explorer
0 Kudos

Hi Sandra,

Thank you for testing it.

What do you mean with controls? The buttons on top of the ALV grid?

Sandra_Rossi
Active Contributor
0 Kudos

Please use the COMMENT button for comments, questions, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.