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: 

color settings in alv display

Former Member
0 Kudos

hi,

plz any one tell how to change colors in alv display or how to set colors in alv

Regards,

jyotsna

9 REPLIES 9

Former Member
0 Kudos

Hi

Search on SDN for "Color a cell or column in ALV report".

Regards

Sachin

Former Member
0 Kudos

hi,

try this links

regards

vivek

Former Member
0 Kudos

Try this link....

Former Member

Former Member
0 Kudos

uwe_schieferstein
Active Contributor
0 Kudos

Hello

You may have a look at sample report ZUS_SDN_ALV_CELL_STYLE_2 in thread to see the effects you can generate in ALV lists.

Regards

Uwe

Former Member
0 Kudos

Hi Jyostna,

For ALV using Function Modules use below code

data: wa_fcat type slis_fieldcat_alv,

fcat type slis_t_fieldcat_alv.

wa_fcat-emphasize = CXYZ.

  • Pass remaining values to waork area and append to field catalog structure*

append wa_fcat to fact.

Pass this table to field catalog option while displaying the ALV output.

X = COLOR for the column possible values 1 to 7.

Y = Intensity for the column possible values 0 / 1.

Z = Inverse the color possible values 0 / 1.

For ALV using Grid Control use the following code.

DATA: begin of gt_list occurs 0.

INCLUDE STRUCTURE SFLIGHT.

DATA rowcolor(4) type c. " Entire Row Color

DATA cellcolors type lvc_t_scol. " Individual cell color

data ne dof gt_list.

DATA ls_cellcolor type lvc_s_scol.

  • While moving selected values to final internal table pass gt_list-rowcolor = CXYZ. to every row to color row. YOu can pass different colors to to display each row in different rows.

Read table gt_list index 5.

ls_cellcolor-fname = 'SEATSOCC'.

ls_cellcolor-color-col = '7'.

ls_cellcolor-color-int = '1'.

APPEND ls_cellcolor to gt_list-cellcolors.

Modify gt_list Index 5.

*The above code to make cell at row 5 and column ''SEATSOCC' colored

Hope this will help you.

Regards,

Kalpana

data

Former Member
0 Kudos

hi jyotsna,

check these link.

saptechnical.com/Tutorials/ALV/ColoredOutput/Program.htm

saptechnical.com/Tutorials/ALV/ColorOnCondition/Program.htm

saptechnical.com/Tutorials/ALV/ColorSALV/Demo.htm

it solves your problems

thanks

Sachin

Former Member
0 Kudos

REPORT z_alv_cell_color.

----


  • Example of ALV with Cell color *

----


  • Macro definition

DEFINE m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = &2.

append ls_fieldcat to lt_fieldcat.

END-OF-DEFINITION.

TYPE-POOLS: slis. " ALV Global types

SELECTION-SCREEN :

SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED

PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY. "#EC *

SELECTION-SCREEN END OF LINE.

TYPES :

BEGIN OF ty_data,

vkorg TYPE vbak-vkorg, " Sales organization

kunnr TYPE vbak-kunnr, " Sold-to party

vbeln TYPE vbak-vbeln, " Sales document

netwr TYPE vbak-netwr, " Net Value of the Sales Order

END OF ty_data,

  • Data displayed

BEGIN OF ty_vbak,

vkorg TYPE vbak-vkorg, " Sales organization

kunnr TYPE vbak-kunnr, " Sold-to party

vbeln TYPE vbak-vbeln, " Sales document

netwr TYPE vbak-netwr, " Net Value of the Sales Order

tabcolor TYPE lvc_t_scol, " Cell Color

END OF ty_vbak.

DATA:

gt_data TYPE TABLE OF ty_data,

  • Data displayed

gt_vbak TYPE TABLE OF ty_vbak.

----


INITIALIZATION.

v_1 = 'Maximum of records to read'. "#EC NOTEXT

----


START-OF-SELECTION.

PERFORM f_read_data.

PERFORM f_fill_color.

PERFORM f_display_data.

----


  • Form f_read_data_vbak

----


FORM f_read_data.

SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_data

FROM vbak UP TO p_max ROWS.

ENDFORM. " F_READ_DATA

----


  • Form f_fill_color

----


FORM f_fill_color.

DATA :

ls_data TYPE ty_data,

ls_vbak TYPE ty_vbak.

LOOP AT gt_data INTO ls_data.

CLEAR ls_vbak.

MOVE-CORRESPONDING ls_data TO ls_vbak.

PERFORM f_modify_color USING 'NETWR' CHANGING ls_vbak.

PERFORM f_modify_color USING 'VBELN' CHANGING ls_vbak.

  • Fill gt_vbak

APPEND ls_vbak TO gt_vbak.

ENDLOOP.

ENDFORM. " F_FILL_COLOR

----


  • Form F_modify_color

----


FORM f_modify_color USING u_fieldname TYPE lvc_fname

CHANGING us_vbak TYPE ty_vbak.

DATA :

l_rnd_value TYPE integer2,

ls_tabcolor TYPE lvc_s_scol.

  • Random value

CALL FUNCTION 'RANDOM_I2'

EXPORTING

rnd_min = 0

rnd_max = 3

IMPORTING

rnd_value = l_rnd_value.

CLEAR ls_tabcolor.

ls_tabcolor-fname = u_fieldname.

CASE l_rnd_value.

WHEN 0.

ls_tabcolor-color-col = 1. " Blue.

ls_tabcolor-color-int = 0.

ls_tabcolor-color-inv = 0.

WHEN 1.

ls_tabcolor-color-col = 3. " Yellow.

ls_tabcolor-color-int = 0.

ls_tabcolor-color-inv = 0.

WHEN 2.

ls_tabcolor-color-col = 5. " Green.

ls_tabcolor-color-int = 0.

ls_tabcolor-color-inv = 0.

WHEN 3.

ls_tabcolor-color-col = 6. " Red.

ls_tabcolor-color-int = 0.

ls_tabcolor-color-inv = 0.

ENDCASE.

INSERT ls_tabcolor INTO TABLE us_vbak-tabcolor.

ENDFORM. " F_MODIFY_COLOR

----


  • Form f_display_data

----


FORM f_display_data.

DATA:

ls_layout TYPE slis_layout_alv,

ls_fieldcat TYPE slis_fieldcat_alv,

lt_fieldcat TYPE slis_t_fieldcat_alv.

  • Build the field catalog

m_fieldcat 'VKORG' 'VBAK'.

m_fieldcat 'KUNNR' 'VBAK'.

m_fieldcat 'VBELN' 'VBAK'.

m_fieldcat 'NETWR' 'VBAK'.

  • Fill Layout

ls_layout-coltab_fieldname = 'TABCOLOR'.

  • Display the list

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

is_layout = ls_layout

it_fieldcat = lt_fieldcat

TABLES

t_outtab = gt_vbak.

ENDFORM. " F_DISPLAY_DATA

                                  • END OF PROGRAM Z_ALV_CELL_COLOR *********************