Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] ALV – Enable Excel Export

The “Excel export” functionality can easily be enabled using get_functions( )->set_all( abap_true )

SELECT * FROM sflight INTO TABLE @DATA(flights) UP TO 100 ROWS.

TRY.
    cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_salv)
                            CHANGING  t_table      = flights ).

    lo_salv->get_functions( )->set_all( abap_true ).
    lo_salv->get_columns( )->set_optimize( abap_true ).
    lo_salv->get_display_settings( )->set_list_header( 'Flights' ).
    lo_salv->get_display_settings( )->set_striped_pattern( abap_true ).
    lo_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

    lo_salv->display( ).

  CATCH cx_root INTO DATA(e_txt).
    WRITE: / e_txt->get_text( ).
ENDTRY.

Leave a Reply

Your email address will not be published. Required fields are marked *