Dynamic columns in table control

Question:
I would like to determine the column headings of a table control dynamically at runtime. Does anyone know if this is possible?
As an alternative, I could create two columns in the table control, then hide the one that is irrelevant given the current system conditions. However, I am unable to do this, either. If I set the screen attributes INVISIBLE = 1 and ACTIVE = 0, the column heading as well as the data in the column are blank, but the column still appears on the screen.
Any help on either approach would be appreciated. I would prefer to just set the column headings dynamically, but if that's not possible, the alternative would be acceptale.
Thanks,
Jim
Answer:
U can do it please go through the help
The table control (referred to here as TC ) facilitates the display and entry of one-line, tabular data in dialog transactions.
The functional scope has been defined so that you can implement many typical set operations that are usually handled by an elementary STEP-LOOP very easily with the standard methods of a TC.
Functional scope
Tabular area for displaying and editing data.
Column width and column position modifiable by user and by program.
Storing and loading of user-specific column layout.
Selection column for line selection with color selection display.
Variable column headers as pushbuttons for column selection.
Single selection, multiple selection, Select/deselect all.
Scrolling functions (horizontal and vertical) via scroll bar.
Fixing of any number of key columns.
Setting attributes for each cell at runtime.
TYPE-POOL CXTAB .
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,
BEGIN OF CXTAB_CONTROL,
FIXED_COLS TYPE I, "Number of fixed columns
LINES TYPE I, "Number of lines to display
TOP_LINE TYPE I, "Top line during next PBO
CURRENT_LINE TYPE I, "Current line during LOOP/ENDLOOP
LEFT_COL TYPE I, "Fist scrollable column after fixed area
LINE_SEL_MODE TYPE I, "Line-selection : none(0), single(1),
COL_SEL_MODE TYPE I, "Column-selection: multiple(2)
LINE_SELECTOR(1) TYPE C, "Indicator: 'With line-selection col'
V_SCROLL(1) TYPE C, "not used
H_GRID(1) TYPE C, "Indicator: 'Horizontal grid-lines'
V_GRID(1) TYPE C, "Indicator: 'Vertikal grid-lines'
COLS TYPE STANDARD TABLE OF CXTAB_COLUMN
WITH NON-UNIQUE DEFAULT KEY,
INVISIBLE(1) TYPE C,
END OF CXTAB_CONTROL,
BEGIN OF CXTAB_TABSTRIP,
ACTIVETAB LIKE SCREEN-NAME,
%_SCROLLPOSITION LIKE SCREEN-NAME,
INVISIBLE(1) TYPE C,
END OF CXTAB_TABSTRIP.
use the above
regards
venkat
Answer:
You can't add or delete columns from your table control at runtime. It's a fixed structure.
You can rename the column headings easily, but that's not the same thing.
Answer:
Set TC-COLS-VISLENGTH to 0.
Answer:
Thanks everyone. Hans-Hermann's suggestion of setting TC-COLS-VISLENGTH = 0 allows me to hide a column. Setting TC-COLS-INVISIBLE = 1 appears to have the same effect.
However, as I stated, my preference is to determine the column headings dynamically. venkat_s and guest11 both indicate that this can be done. However, I don't find anything in the help describing how to do this. Can anyone point me in the right direction?
Thanks very much for your help.
Jim
Answer:
Never mind, I figured it out. I had to define my column headings as input/output fields instead of text fields. Thanks again for the help.
Jim
Answer:
Hi,
Try to change TC-COLS-SCREEN-NAME .
Regards
venkat
Answer:
hi,
u can have dynamic columns in an internal table.
i have done in my transfer postings component.
declare as many columns as u like initially. u can hide the display of the columns as and when u wish..
it is possible with the use of TYPE-POOLS cxtab.
declare TYPE-POOLS cxtab.
DATA v_tccols TYPE cxtab_column .
FIELD-SYMBOLS: <tc_cols> TYPE cxtab_control .
data tcname(25) type c.
assign table control name to tcname and assign tcname to tc_cols.
with this u can manipulate what ever columns u want to display or hide.
try this out.
if u want i can send u complete code.
best of luck,
.....

More Articles:

To report conversion errors?
How to find out Material Memo Table?
Field Exit?
Anyone of you used SNOTE transaction?
delete development class and all objects under it?
Change SAP standard program?