In this tutorial we will explain how to hide a column in a table control use in a Dynpro screen.
As example, we will hide a column in the table control ‘TC_DLSAM’ (used in the MRP transaction MD06).
Step 1:
In the flow logic of the screen where the table control is used, we will have to call a module in the screen PBO (Process Before Output) which will contains the appropriate code logic to hide the column.
Code to call the module ‘F_HIDE_COLUMN’:
*---------------------- PROCESS BEFORE OUTPUT. *---------------------- * Some Codes… * Calling the module which will hide the column. MODULE f_hide_columns.
Step 2:
The following code will hide the column ‘MRP Date’ from the table control ‘TC_DLSAM’.
Code:
*----------------------------------------------------------------------*
* Hiding the column \'MRP Date\' in the table control \'TC_DLSAM\' in *
* screen 602 of transaction MD06. *
*----------------------------------------------------------------------*
MODULE f_hide_column OUTPUT.
*----------------------------------------------------------------------*
* Other Declarations may be needed:
* CONTROLS: tc_dlsam TYPE TABLEVIEW USING SCREEN 602.
* TYPE-POOL CXTAB .
* TYPES CXTAB_COLUMN type scxtab_column.
* Types:
DATA:
lst_cols TYPE cxtab_column.
* Constants:
CONSTANTS:
lc_column_mrp_date TYPE char10 VALUE \'MDKE-DSDAT\'.
* We will have to loop at the standard table control \'TC_DLSAM\'
* deep structure \'COLS\' and we will modify the display attribute
* of column \'MRP Date\' to hide it on the report.
LOOP AT tc_dlsam-cols INTO lst_cols.
* If the column name equals to \'MDKE-DSDAT\'(MRP Date), proceed.
IF lst_cols-screen-name EQ lc_column_mrp_date.
* Set the \'Invisible\' display attribute of column \'MRP Date\'
* to true to hide it.
lst_cols-invisible = 1.
* Modify the table control deep structure \'COLS\' with the new
* display attribute for column \'MRP Date\'.
MODIFY tc_dlsam-cols FROM lst_cols
INDEX sy-tabix.
ENDIF.
* As a best practice, clear the structure
* as its inside a loop.
CLEAR:
lst_cols.
ENDLOOP.
ENDMODULE. \" F_HIDE_COLUMN OUTPUT