2009 Feb 25 10:13 AM
Hello,
I have a table control and I want to change color for alternate rows.
How to do make zebra line for the table control?
Regards,
RH
2009 Feb 25 10:21 AM
Hi,
You can use loop at screen inside the loop with <tab_ctrl> , and can alternative use code:-
screen-intensified = '1'.
screen-intensified = '0'.
This will color the text no the background.
In module pool you cant color in background, but can use ALV to do so.
For Color in alv refer code in wiki:-
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/coloring%252ba%252brow%252band%252bc
Hope this solves your problem.
Thanks & Regards,
Tarun
Edited by: Tarun Gambhir on Feb 25, 2009 3:52 PM
2009 Feb 25 10:21 AM
Hi,
You can use loop at screen inside the loop with <tab_ctrl> , and can alternative use code:-
screen-intensified = '1'.
screen-intensified = '0'.
This will color the text no the background.
In module pool you cant color in background, but can use ALV to do so.
For Color in alv refer code in wiki:-
https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/coloring%252ba%252brow%252band%252bc
Hope this solves your problem.
Thanks & Regards,
Tarun
Edited by: Tarun Gambhir on Feb 25, 2009 3:52 PM
2009 Feb 25 10:26 AM
HI,
please check this code
To change the colour of any column in a table control on screen, use code:-
In the PAI of the screen, inside
loop with control <tab_ctrl_name>.
module modify_tab.
endloop.
Say for a column, you take group1 as 'ABC'.
In this module you can use the group for the input/output fields and intensify them as per your requirements.
module modify_tab.
if <condition>.
loop at screen.
if screen-group1 = 'ABC'. "say textbox (column for a table) has group1 as ABC
screen-intensified = 'X'. "change the colour
endif.
modify screen.
elseif <condition>.
loop at screen.
if screen-group1 = 'ABC'. "say textbox (column for a table) has group1 as ABC
screen-intensified = ' '. "change the colour
endif.
modify screen.
endif.
endmodule.
Similarly, you can use this code for other columns also.
Hope this solves your prolem.
Thanks and regards
Durga.K
2009 Feb 25 10:58 AM
Hi Ronny,
just check zebra field in layout and pass to method set_table_for_first_display..
it wud serve the purpose..
data: w_idx type i.
data:
begin of t_itab occurs 0.
include structure sflight.
data end of t_itab.
**declaring the container & grid for output table display**
data:
r_container type ref to cl_gui_custom_container,
r_grid type ref to cl_gui_alv_grid.
**structure of layout**
data:
fs_lay type lvc_s_layo.
**Field Catalog**
data:
t_fcat type lvc_t_fcat,
fs_fcat type lvc_s_fcat.
select * from sflight into corresponding fields of table t_itab.
fs_lay-zebra = 'X'.
call screen 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module status_0100 output.
set pf-status 'SCREEN1'.
endmodule. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module user_command_0100 input.
case sy-ucomm.
when 'BACK'.
leave to screen 0.
when 'EXIT'.
leave program.
endcase.
endmodule. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module LIST OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module list output.
create object r_container
exporting
container_name = 'CONTAINER'.
create object r_grid
exporting
i_parent = r_container.
*passing the layout structure, fieldcatalog and output table for display*
call method r_grid->set_table_for_first_display
exporting
i_structure_name = 'SFLIGHT'
IS_LAYOUT = fs_lay
changing
it_fieldcatalog = t_fcat
it_outtab = t_itab[].
endmodule. " LIST OUTPU
Regards.
Mdi.Deeba
2009 Feb 25 11:20 AM
Hi,
check with following link for make zebra line for the table control.
http://help.sap.com/saphelp_sm32/helpdata/en/d1/802338454211d189710000e8322d00/content.htm
Thanks,
Neelima