‎2008 Apr 05 9:17 AM
Hi All,
Can anyone tell me how to disable any column of table control at runtime.
your help will be rewarded.
thx
‎2008 Apr 05 10:05 AM
Hi Vipul,
we can disable the column by making it display only
Now assume the name of your table control is ZTABLECONT..double click on the screen painter on the table control..these 2 names must be the same....
data declaration:
data : cols like line of ZTABLECONT-cols.
loop at ZTABLECONT-cols into cols.
if cols-screen-input = '1'.
cols-screen-input = '0'.
endif.
modify ZTABLECONT-cols from cols index sy-tabix.
endloop.
This will disable all the columns
for a particular column do the following
For this imagine you have 5 columns
in the below code
index = 1 => column 1
index = 2 => column 2
index = 3 => column 3
index = 4 => column 4
index = 5 => column 5
in the below code , only column2 will be disabled....
so whicever column you want to disable ..just give the index
for multiple disabling..just write the code accordingly
LOOP AT ZTABLECONT-cols INTO cols WHERE index = 2.
IF cols-screen-input = '1'.
cols-screen-input = '0'.
ENDIF.
MODIFY ZTABLECONT-cols FROM cols INDEX sy-tabix.
ENDLOOP.
The above code can be written in PAI or PBO as per your requirement
For eg: if on entering the screen for the first time..for a particular condition you need the columns disabled means write it in PBO
if you need to disable columns of table control as a part of user action..like say click of a button..it can be entered in PAI by checking the sy-ucomm
Pls check and revert...the code works and is being used in active code
Reward if helpful
Regards
Byju
‎2008 Apr 05 10:05 AM
Hi Vipul,
we can disable the column by making it display only
Now assume the name of your table control is ZTABLECONT..double click on the screen painter on the table control..these 2 names must be the same....
data declaration:
data : cols like line of ZTABLECONT-cols.
loop at ZTABLECONT-cols into cols.
if cols-screen-input = '1'.
cols-screen-input = '0'.
endif.
modify ZTABLECONT-cols from cols index sy-tabix.
endloop.
This will disable all the columns
for a particular column do the following
For this imagine you have 5 columns
in the below code
index = 1 => column 1
index = 2 => column 2
index = 3 => column 3
index = 4 => column 4
index = 5 => column 5
in the below code , only column2 will be disabled....
so whicever column you want to disable ..just give the index
for multiple disabling..just write the code accordingly
LOOP AT ZTABLECONT-cols INTO cols WHERE index = 2.
IF cols-screen-input = '1'.
cols-screen-input = '0'.
ENDIF.
MODIFY ZTABLECONT-cols FROM cols INDEX sy-tabix.
ENDLOOP.
The above code can be written in PAI or PBO as per your requirement
For eg: if on entering the screen for the first time..for a particular condition you need the columns disabled means write it in PBO
if you need to disable columns of table control as a part of user action..like say click of a button..it can be entered in PAI by checking the sy-ucomm
Pls check and revert...the code works and is being used in active code
Reward if helpful
Regards
Byju
‎2008 Apr 05 11:27 AM
‎2008 Apr 06 5:51 AM
Hi Vipul,,
the ans given above is at compile time or hard coding...
as u asked for something at run time, i think the following will help you...
Use screen end screen option and set the screen element's active attribute to inactive.
you can see the variuos options available by pressing f1 help on "screen".
This is the best way to do this as it happens at runtime only wen required.
Do Reward and get back if any trouble.