How to hide columns in table control?

Question: Hello all,

I've tried looking in the forums if there was any topic related to this, but it seems that there aren't any.

I'm currently doing a dialog program which initially, in the selection screen, has a choice on the columns that are to be displayed. It is possible for me to input the values of my output display into two tables, but I would like to know if there was a way for me to selectively hide certain columns in a table control? I think that simply hiding the columns would be more efficient that having to create multiple tables.

Thanks in advance for any help,
Diana Flaviano

Answer:
Your table control is typed as tableview. The structure of it is like CXTAB_CONTROL in Type Pool CXTAB.

Take a look and you will see one element of CXTAB_CONTROL is the table COLS, which controls the columns of table control. And this table has a controlfield named 'INVISIBLE'. If this flag is set, the column will be hided.

Use statement READ TABLE and MODIFY TABLE to manipulate the flag.

Answer:
* ---- data part
TYPES: BEGIN OF CXTAB_COLUMN,
SCREEN LIKE SCREEN, "Attributes struktur SCREEN
INDEX TYPE I, "Position of a column on the screen
SELECTED(1) TYPE C, "Indicator 'column selected'
VISLENGTH LIKE ICON-OLENG, "Visualised length of a column
INVISIBLE(1) TYPE C, "Indicator 'column invisible'
END OF CXTAB_COLUMN.

DATA: W_TABCONCOL TYPE CXTAB_COLUMN ,


* ---- in the program

LOOP AT TC_MAIN-COLS[] INTO W_TABCONCOL
WHERE SCREEN-NAME = 'field name'.
W_TABCONCOL-SCREEN-INVISIBLE = 1.
W_TABCONCOL-INVISIBLE = 1.
MODIFY TC_MAIN-COLS FROM W_TABCONCOL.
ENDLOOP.
_________________
don't dream it ' , do it .
Copyright ?2007 - 2008 www.jt77.com