Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Coloring of ROWS in ALV tree

Former Member
0 Kudos

Hi All,

I have created an alv tree report and i need to colour the entire row of the tree. I am able to colour the entire row but the colour is getting refelected only on the fonts not on the background.I have used the add_node method and passed the colour code to the is_node_layout parameter of it.The strange thing is when is when i use the colour code greater than 5 the the entire row is getting coloured including the background but if i use the colour code less than 5 then only the fonts are getting coloured.

Plz let me know what iam missing .Its quite urgent

14 REPLIES 14

Former Member
0 Kudos

Use option "emphasize" of the field catalogue.

Color code is set as follows :

'Cxyz'

where x = color number

y = 1 or 0 (intensified on/off)

z = 1 or 0 (inverse on/off )

color 1 to 7

Hope this help you.

Regards,

Erwan.

ssimsekler
Active Contributor
0 Kudos

Hi

I guess coloring is achieved by the similar way in ALV Grid. So pass to the color variable:

<b>'Cxyz'</b> where ;

x: Color number (1-7)

y: Intensified on/off (1/0)

z: Inverse on/off (1/0)

Color codes are;

x Color Intended for

1 gray-blue headers

2 light gray list bodies

3 yellow totals

4 blue-green key columns

5 green positive threshold value

6 red negative threshold value

7 orange Control levels

*--Serdar

-


Ups! Answered concurrently

Message was edited by: Serdar Simsekler

Former Member
0 Kudos

Hi Umang,

You can change the color of columns and rows in the grid control to highlight data in the list.

The column color can be set using field EMPHASIZE of the field catalog.

EMPHASIZE = 'X' - Using predefined colors.

EMPHASIZE = 'Cxyz' (where x=COLOR code as with FORMAT statement, y=INTENSIFIED 0=Off 1 = On, z=INVERSE 0=Off 1 = On).

For row colors however it works differently.

Follow these steps:

1. You must define your own layout structure of type LVC_S_LAYO .

2. Add a four-digit character field to your output table, as shown in the example below:

DATA: BEGIN OF GT_OUTTAB OCCURS 0.

INCLUDE STRUCTURE <DDIC-Struktur>.

DATA: linecolor(4) type c. "Color for corresponding line

DATA: END OF GT_OUTTAB.

3. Select your data and copy it into the output table.

4. Loop over your output table. To change the color of a row, assign a four-digit color code to the character field similar to the color code used with EMPHASIZE (= 'Cxyz') in the Column colors.

Thus 1st character = 'C'.

2nd character = your color code value (range 0-9).

3rd character = Control of INTENSIFIED (0=Off, 1=On)

4th character = Control of INVERSE (0=Off, 1=On)

5. Assign the name of the internal table to field INFO_FNAME of the layout structure (in our case 'LINECOLOR' , see step 2).

Pass the layout structure and the output table with method set_table_for_first_display.

If you do not want to color the cells for the first display, postpone step 4 and refresh the output table with method refresh_table_display.

This procedure is the correct one.

Regards,

Rob.

0 Kudos

Hi Rob,

Thanks for the input , but the problem still remains actualy i have developed an ALV tree.And iam using the class CL_GUI_ALV_TREE in which the method set_table_for_first display does not have a parameter for a layout.The info_name parameter is not there at all.

I know the solution which you have given is good for ALV grid but i belive it wont work for ALV tree.

If there is anything else which can be done plz let me know.

"I need a solution for ALV tree"

Cheers

Umang

0 Kudos

Hi Umang,

Can you bit elaborate on your requirement. Because seems what Rob is referring to should serve your purpose.

0 Kudos

Hi Deepak,

The problem which i am facing is that the method Set_table_for_first display for the class cl_gui_alv_tree does not have the parameter for a layout. Now when iam not able to pass the parameter for layout how will color the rows then. The info_name is a parameter in the method set_table_for_first_display you can see that the names for the methods are same but there classes are different one is for cl_gui_alv_tree and the other is for cl_gui_alv_grid.

0 Kudos

Hi Umang

As far as I inspected the ALV Tree class, it seems not possible to fulfil your requirement. You can set the style of text and thus its color, but not the background of it.

But now I remembered to look for some styles having "inverse" characteristic. Let me look for it. However, unfortunatelt, I am not so hopeful.

*--Serdar

Former Member
0 Kudos

Hi Umang,

today i've seen your post about coloring ALV tree rows. Have you found the way to do this? I'm searching for the same solution of my problem, too. You said that coloured onlye fonts, how did you do this? Can you put some sample code?

Thanks,

> Hi All,

> I have created an alv tree report and i need to

> o colour the entire row of the tree. I am able to

> colour the entire row but the colour is getting

> refelected only on the fonts not on the background.I

> have used the add_node method and passed the colour

> code to the is_node_layout parameter of it.The

> strange thing is when is when i use the colour code

> greater than 5 the the entire row is getting coloured

> including the background but if i use the colour code

> less than 5 then only the fonts are getting

> coloured.

> Plz let me know what iam missing .Its quite urgent

Karan_Chopra_
Active Participant
0 Kudos

plz help on this

Former Member
0 Kudos

Hi,

First you take a additional column in Internal Table for this purpose.

Before creating the field cata log you can call the function to assign the color to this column.

form data_retrieval.

data: ld_color(1) type c.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 20 rows

from ekpo

into table it_ekko.

ld_color = ld_color + 1.

*Populate field with color attributes

loop at it_ekko into wa_ekko.

IF wa_ekko-MEINS = 'KG'." Here I am giving a color to the row having MEINS = 'KG'

concatenate 'C' ld_color '10' into wa_ekko-line_color.

ENDIF.

modify it_ekko from wa_ekko.

endloop.

endform.

After calling this function you can build your field catalog and pass the internal table to your function 'REUSE_ALV_GRID_DISPLAY'.

Please let me know if you have any problem in this code .

With Regards.

Edited by: Avenai on Jul 8, 2010 1:03 PM

0 Kudos

You can color items in alv tree - using item_layout table:

style = cl_gui_column_tree=>style_emphasized_positive

if you done this for all fields in fieldcatalog - effect of coloring row may be done

Former Member
0 Kudos

If u r in version ECC 6.0 then

go to se38

execute program ITSQ_ALV_COLOR

Hi Umang...

lots of discussion going on already...

Your requirement can be handled when creating the node for the tree using method ADD_NODE of CL_GUI_ALV_TREE...There is a importing parameter IT_ITEM_LAYOUT...In this table you need to fill the FIELDNAME which is to be coloured and the field STYLE...

Now thr is a restriction that u cannot have all the seven colours for the field background...SAP has provided a set of colours that can be passed into the STYLE field...

It will make it a lot easier if you refer to the program BCALV_TREE_ITEMLAYOUT..execute this report, open the tree to display a item..click on any of the columns and then change the style by clicking on the style button in the toolbar...you can get to see the colours the cells take and choose...

Hope this helps...

Regards,#

Sitakant

Edited by: Sitakant Tripathy on Sep 13, 2010 3:21 PM

mkysoft
Participant
0 Kudos

You can use these as node (row) style:

STYLE_DEFAULT (normal)

STYLE_INTENSIFIED (blue)

STYLE_INACTIVE (grey)

STYLE_INTENSIFD_CRITICAL (red)

STYLE_EMPHASIZED_NEGATIVE (red background)

STYLE_EMPHASIZED_POSITIVE (green background)

STYLE_EMPHASIZED (yellow background)

STYLE_EMPHASIZED_A (blue background)

STYLE_EMPHASIZED_B (grey background)

STYLE_EMPHASIZED_C (orange background)

You can use them in when you are adding nodes:

data: LS_NODE type LVC_S_LAYN.

LS_NODE-STYLE = CL_GUI_COLUMN_TREE=>STYLE_INACTIVE.

call method TREE1->ADD_NODE

     exporting

       I_RELAT_NODE_KEY = P_RELAT_KEY

       I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD

       I_NODE_TEXT      = L_NODE_TEXT

       IS_OUTTAB_LINE   = LS_ROW

       IS_NODE_LAYOUT   = LS_NODE

       IT_ITEM_LAYOUT   = LT_ITEM_LAYOUT.

This options are limited