jsonxmlabapalv

Capture any standard report to JSON or XML?


I know that I can use LIST_TO_ASCI to convert a report to ASCII, but I would like to have a more high level data format like JSON, XML, CSV.

Is there a way to get something that is easier to handle then ASCII?

Here is the report I'd like to convert:

enter image description here

The conversion needs to be executed in ABAP on a result which was executed like this:

SUBMIT <REPORT_NAME> ... EXPORTING LIST TO MEMORY AND RETURN.

Solution

  • I found a solution here: http://zevolving.com/2015/07/salv-table-22-get-data-directly-after-submit/

    This is the code:

    DATA: lt_outtab TYPE STANDARD TABLE OF alv_t_t2.
    FIELD-SYMBOLS: <lt_outtab> like lt_outtab.
    DATA lo_data TYPE REF TO data.
    
    " Let know the model
     cl_salv_bs_runtime_info=>set(
      EXPORTING
        display  = abap_false
        metadata = abap_false
        data     = abap_true
    ).
    
    
    SUBMIT salv_demo_table_simple
      AND RETURN.
    
    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.
    

    Big thanks to Sandra Rossi, she gave me the hint to cx_salv_bs_sc_runtime_info.

    Related answer: https://stackoverflow.com/a/52834118/633961