The SALV hide column/field or cell functionality is much the same as changing the header text you simply use the column variable and set_visible to false to hide it. If you install the example SALV report which includes the basic code below for hiding field SEATSOCC_F, along with how to set the colour of individual rows, columns or fields.
column = salv_columns->get_column( 'SEATSOCC_F' ). column->set_visible( if_salv_c_bool_sap=>false ). " hide a specifi SALV column
Hide multiple fields of a SALV report
But we could just as easily hide multiple fields by adding the following code to the program
column = salv_columns->get_column( ‘FLDATE’ ).
column->set_visible( if_salv_c_bool_sap=>false ).
column = salv_columns->get_column( ‘PRICE’ ).
column->set_visible( if_salv_c_bool_sap=>false ).
column = salv_columns->get_column( ‘CURRENCY’ ).
column->set_visible( if_salv_c_bool_sap=>false ).
column = salv_columns->get_column( ‘PLANETYPE’ ).
column->set_visible( if_salv_c_bool_sap=>false ).
“Existing code
column = salv_columns->get_column( ‘SEATSOCC_F’ ).
column->set_visible( if_salv_c_bool_sap=>false ).
If using the example the code should now look like this
And the report should output without the hidden fields
Why use SALV hide to remove a field/column/cell
The question is why to use the hide functionality within instead of just deleting the field from the grid altogether. The main benefit of hiding SALV fields instead of deleting them is that they still exist on the report and can be added back onto the report by a user at any point, by simply using the built-in change layout functionality of standard SAP ALV and SALV reports.
How to restore hidden fields to the ALV report
To do this first click on the change layout icon
The hidden fields will then appear in the righthand side of the change layout popup for you to select from
Simply select the fields you want to add and use the arrows to move the fields acrosss
Click the green tick and the selected fields will be added to the output report