ABAP: ALV using class CL_SALV_TABLE

Here is a sample code to create a simple ALV report.

 data: go_alv   type ref to cl_salv_table.
 
  if not gt_out is initial.
    try.
        cl_salv_table=>factory(
*        exporting list_display = abap_true
          importing
            r_salv_table = go_alv
          changing
            t_table      = gt_out ).
      catch cx_salv_msg.                                "#EC NO_HANDLER
    endtry.
  
* setting default ALV generic funtions
    data(lo_functions) = go_alv->get_functions( ).
    lo_functions->set_all( ).
 
*... §8 display the table
    go_alv->display( ).

SAP standard programs using class CL_SALV_TABLE can be found using the following program name pattern
SALV* or SALV*DEMO*.

PS: Note that SALV has its own limitations. One of them is related to displaying an image at the header. This is not possible when using SALV class.

Additional reference:
https://wiki.scn.sap.com/wiki/display/ABAP/ALV+Grid+Report+-+with+Object+Oriented+SALV+Classes

https://blogs.sap.com/2014/02/15/how-to-extract-formatted-output-as-an-excel-document-using-salv-in-the-background/

Leave a Reply