2012 Jan 27 6:00 AM
Hi All,
I have a simple requirement. My requirement is I would Like to Color a ALV grid Cell.
But, I want to color the cell in two ways.
1. Background Color of the particular Cell must be one color (Lets Say Yellow)
2. Text Color of the Particular Cell must be one color (Lets Say Red).
I have gone through many options like coloring a particular cell either background or Text.
But not both with different colors.
Please suggest that any one has done this in SAP.
Thanks in Advance.
Venkat
2012 Jan 27 6:34 AM
2012 Jan 27 7:01 AM
Hi,
Use this code to Background Color of the particular Cell .Try with the below Code definitely it works.
Example Code :
Data:gd_layout type slis_layout_alv.
gd_LAYOUT-coltab_fieldname = 'CELLCOLOR'.
DATA: WA_CELLCOLOR TYPE LVC_S_SCOL.
DATA: ld_index TYPE SY-TABIX.
LOOP AT IT_EKKO into wa_ekko.
LD_INDEX = SY-TABIX.
Set colour of EBELN field to various colors based on sy-tabix value
WA_CELLCOLOR-FNAME = 'EBELN'.
WA_CELLCOLOR-COLOR-COL = sy-tabix. "color code 1-7, if outside rage defaults to 7
WA_CELLCOLOR-COLOR-INT = '1'. "1 = Intensified on, 0 = Intensified off
WA_CELLCOLOR-COLOR-INV = '0'. "1 = text colour, 0 = background colour
APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
Set colour of NETPR field to color 4 if gt 0
if wa_ekko-netpr gt 0.
WA_CELLCOLOR-FNAME = 'NETPR'.
WA_CELLCOLOR-COLOR-COL = 4. "color code 1-7, if outside rage defaults to 7
WA_CELLCOLOR-COLOR-INT = '0'. "1 = Intensified on, 0 = Intensified off
WA_CELLCOLOR-COLOR-INV = '0'. "1 = text colour, 0 = background colour
APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
endif.
Set colour of AEDAT field text to red(6)
WA_CELLCOLOR-FNAME = 'AEDAT'.
WA_CELLCOLOR-COLOR-COL = 6. "color code 1-7, if outside rage defaults to 7
WA_CELLCOLOR-COLOR-INT = '0'. "1 = Intensified on, 0 = Intensified off
WA_CELLCOLOR-COLOR-INV = '1'. "1 = text colour, 0 = background colour
APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
ENDLOOP.
2012 Jan 27 9:46 AM
Hi All,
Thanks for the comments. I clearly mentioned in the requirement that, I already googled and tested all the comments mentioned here.
Once again for a better Idea. My Requirement is : In the ALV GRID Cell, It should Have Back ground as Yellow and the Text in it should be Red.
Shravan, it was a good option to EMPHASIZE. But FYI... When we are already using LVC_S_SCOL to color the Text. we cant use EMPHASIZE.
Please let me know any other suggestions.
Thanks In Advance,
Venkat.
Edited by: VENKAT SESHA on Jan 27, 2012 10:46 AM
2012 Jan 27 10:53 AM
Hi Venkat,
I do not think this is possible. Last year I was searching for the same requirement which you are after.
Lets hope a solution is available Now.
Cheers!
2012 Jan 27 11:36 AM
Hi Venkat,
The requireoment with reference to cell is not possible i guess. But with reference column is possible class : CL_SALV_COLUMNS_TABLE
Thanks & Regards
Suresh Nair