SLAV tutorial to HIDE SAP ALV column when using CL_SALV_TABLE ABAP object method

This builds on the basic CL_SALV_TABLE ALV example and then shows you how to hide a specific column of the ALV output report.


*&---------------------------------------------------------------------*
*& Report  ZSALV_BASIC
*&---------------------------------------------------------------------*
*& Display very basic ALV report using CL_SALV_TABLE
*&---------------------------------------------------------------------*
REPORT ZSALV_BASIC.
*Data Declaration
*----------------
DATA: it_sflight TYPE TABLE OF sflight.
DATA: alv_table  TYPE REF TO cl_salv_table.
data: alv_columns TYPE REF TO cl_salv_columns_table.
data: alv_column  TYPE REF TO cl_salv_column_table.
************************************************************************
*START-OF-SELECTION.
START-OF-SELECTION.
  SELECT *
    FROM sflight
    INTO TABLE it_sflight.
* Create instance of ALV table object
  CALL METHOD cl_salv_table=>factory
    IMPORTING
      r_salv_table = alv_table
    CHANGING
      t_table      = it_sflight.

* hide CARRID column
  alv_columns = alv_table->get_columns( ).
  alv_column ?= alv_columns->Get_Column( 'CARRID' ).
  alv_column->set_visible( abap_false ).

* Display ALV table.
  alv_table->display( ).



Also See SALV tutorials for a more information about creating ALV reports using cl_salv_table including very basic example using 10 lines of code and setting custom header texts and selecting which fields to output.


Related Articles

ABAP SALV CL_SALV_TABLE method to create ALV in less than 10 lines of code
SALV tutorial to use CL_SALV_TABLE class to create basic ABAP ALV report within SAP