Posted: Fri Jun 04, 2010 11:24 am Post subject: Color individual cells of an ALV GRID
Author: Ankur Parab
The coloring of individual cells in ALV Grid is possible through ALV using OOPS.
First declare a table (of type lvc_t_scol) for specifying the color inside the internal table which contains the values to be displayed.
c_col type lvc_t_scol, " For cell coloring
Now after populating the internal table, modify the field c_col by specifying the color and the field name.
There can be any number of such rows in the internal table.
form set_color .
data: wa_col type lvc_s_scol.
wa_col-fname = 'SORTL'.
wa_col-color-col = '7'.
read table it_temp into wa_temp index 5.
append wa_col to wa_temp-c_col.
modify it_temp from wa_temp index 5.
Now set the ctab_fname attribute of the layout can be set to the name of the color table, which is C_COL.
gs_layout-ctab_fname = 'C_COL'.
Now call the method set_table_for_first_display to display the ALV.
This code snippet will help you understand how to color individual cells in an ALV GRID object.
types: begin of y_t_itab,
matnr type matnr,
maktx type maktx,
colortab type lvc_t_scol,
end of y_t_itab.
data : itab type standard table of y_t_itab.
data : color_tab type standard table of lvc_s_scol.
data : it_fcat type standard table of lvc_s_fcat.
data : wa_itab type y_t_itab.
field-symbols: <f_wa_itab> type y_t_itab.
data : wa_fcat type lvc_s_fcat,
wa_layo type lvc_s_layo,
wa_color type lvc_s_scol.
data : gc_container type ref to cl_gui_custom_container,
gc_grid type ref to cl_gui_alv_grid.
select-options : s_matnr for wa_itab-matnr.
select matnr maktx from makt
into corresponding fields of table itab
where matnr in s_matnr
and spras = sy-langu.
if sy-subrc eq 0.
sort itab by matnr.
call screen '0100'.
module status_0100 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.