My table has around 300 columns and I want to display only 10 out of them with specifying which ones. I am working with CL_SALV_TABLE
.
Can anybody help me with this problem or give me a hint? Thank you very much in advance!
You need to use the method SET_VISIBLE
of the Column object (class CL_SALV_COLUMN
). For more information, see the chapter "Set the Visibility of the Column" of page "Columns (General)" .
This Minimal reproducible example shows only the columns SPRAS
and LAISO
from the table T002
, all other ones are hidden:
DATA: t002_lines TYPE TABLE OF t002,
salv TYPE REF TO cl_salv_table,
columns TYPE salv_t_column_ref.
FIELD-SYMBOLS <column> TYPE salv_s_column_ref.
SELECT * FROM t002 INTO TABLE t002_lines.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = salv
CHANGING
t_table = t002_lines.
LOOP AT salv->get_columns( )->get( ) ASSIGNING <column>.
CASE <column>-columnname.
WHEN 'SPRAS' OR 'LAISO'.
<column>-r_column->set_visible( if_salv_c_bool_sap=>true ).
WHEN OTHERS.
<column>-r_column->set_visible( if_salv_c_bool_sap=>false ).
ENDCASE.
ENDLOOP.
salv->display( ).
This code is used to hide all columns of a table except the ones specified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.