SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Coloring Cells/rows in ALV Grid.



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Fri Jun 04, 2010 11:18 am    Post subject: Coloring Cells/rows in ALV Grid. Reply with quote

Author: Stefan Riedel-Seifert

You must distinuish between 3 Scenarios fpr coloring:

1) Coloring entire column
To make an entire column be painted with the color you want, you can use the "emphasize" option of the field catalog. Simply assign a color code to this field of the row added fpr your column. Color codes are constructed as follows:
Cxyz:

x: 1-7 (1 for example is gray-blue, 6 is red)
y: intensified on/off
z: inverse on/off

e.g. C600 is red inverse off and intensified off.
Code:
*****************************************************************
* Colour code :                                                 *
* Colour is a 4-char field where :                              *
*              - 1st char = C (color property)                  *
*              - 2nd char = color code (from 0 to 7)            *
*                                  0 = background color         *
*                                  1 = blue                     *
*                                  2 = gray                     *
*                                  3 = yellow                   *
*                                  4 = blue/gray                *
*                                  5 = green                    *
*                                  6 = red                      *
*                                  7 = orange                   *
*              - 3rd char = intensified (0=off, 1=on)           *
*              - 4th char = inverse display (0=off, 1=on)       *
*                                                               *
* Colour overwriting priority :                                 *
*   1. Line                                                     *
*   2. Cell                                                     *
*   3. Column                                                   *
*****************************************************************


2) Coloring an entire row
Coloring a row is a bit more complicated. to enable row coloring, you should add an additional field to your list data table. It should be of character type and at least 4 bit long. Thisfield will contain the color code for the row. So for example:
Code:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE <your structure>.
DATA rowcolor(4) TYPE c.
DATA: END OF gt_list.


As you guess, you should fill the color code to this field. Its format is as explained before. For second you must pass the name of the field to the layout structure:
e.g.
Code:
ps_layout-info_fname = 'ROWCOLOR'.


3) Coloring individual cell:

Likely coloring rows, you must append a internal table to each line of gt_list containing the color information:
Code:
DATA: BEGIN OF gt_list occurs 0.
INCLUDE STRUCTURE <your structure>.
DATA cellcolors TYPE lvc_t_scol.
DATA: END OF gt_list.


If you want to modify the cell in the 5 row and the 2 column, you have to set:

Code:
DATA: cellcolor type line of lvc_t_scol.
READ TABLE gt_list INDEX 5.

cellcolor-fname = <name of the second field in your structure>. " Name of colored column
cellcolor-color-col = '6'. "Color of cell
cellcolor-color-int = '0'.
APPEND cellcolor TO gt_list-cellcolors.
modify GT_LIST INDEX 5.


As like coloring rows, you have to pass the info for coloring cell to the layout-structure:

Code:
ps_layout-info_ctab_fname = 'CELLCOLOR'.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.