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: 

Report color

Former Member
0 Kudos

Hi How to get red color for particular field ?

How to get some color for particular record ?

Plz Explain with code?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi

data line_color(4) type c.

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • Set layout field for row attributes(i.e. color)

gd_layout-info_fieldname = 'LINE_COLOR'.

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

<b>sample code to change colour</b>

form data_retrieval.

data: ld_color(1) type c.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

*Populate field with color attributes

loop at it_ekko into wa_ekko.

  • Populate color variable with colour properties

  • Char 1 = C (This is a color property)

  • Char 2 = 3 (Color codes: 1 - 7)

  • Char 3 = Intensified on/off ( 1 or 0 )

  • Char 4 = Inverse display on/off ( 1 or 0 )

  • i.e. wa_ekko-line_color = 'C410'

ld_color = ld_color + 1.

  • Only 7 colours so need to reset color value

if ld_color = 8.

ld_color = 1.

endif.

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

  • wa_ekko-line_color = 'C410'.

modify it_ekko from wa_ekko.

endloop.

endform. " DATA

regards

ravish

<b>plz reward points if helpful</b>

7 REPLIES 7

anversha_s
Active Contributor
0 Kudos

hi,

1. declare one field say color in the output table of type

SLIS_T_SPECIALCOL_ALV.

2. Also declare a table color like

DATA COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.

3. After you have filled the field catalog do like this,

LOOP AT IT_ALV_DATA.
IF SY-TABIX = 2.
COLOR-FIELDNAME = 'POSNR'.
COLOR-COLOR-COL = 6.
COLOR-COLOR-INT = 0.
APPEND COLOR.
IT_ALV_DATA-COLOR = COLOR[].
MODIFY IT_ALV_DATA.
ENDIF.
ENDLOOP.

for a particular record.

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm

Rgds

Anversha

Former Member
0 Kudos

TRY LIKE THIS

LOOP AT ITAB.

FORMAT COLOR 5.

WRITE : / ITAB-MATNR.

FORMAT COLOR OFF.

FORMAT COLOR 3.

WRITE : ITAB-WERKS.

FORMAT COLOR OFF.

FORMAT COLOR 4.

WRITE : ITAB-LGORT.

FORMAT COLOR OFF.

ENDLOOP.

LIKE THIS DIFFERENT COLOR FOR DIFFERENT COLOUMN.

REGARDS

SHIBA DUTTA.

Former Member
0 Kudos

Hi..

<b>FORMAT COLOR <n> [ON] INTENSIFIED [ON|OFF] INVERSE [ON|OFF].</b>

FORMAT COLOR 6.

WRITE: / 'Rammohan'.

Former Member
0 Kudos

hi balu,

u can use FORMAT COLOR (0 TO 7) to get different colors for a field.

Regards...

Arun.

Reward points if useful.

Former Member
0 Kudos

In normal report , u can try this to color a record

loop at itab.
 if sy-tabix eq 3.
 FORMAT COLOR 3.          " to color third row
   write : itab-field1 , itab-field2.
 FORMAT COLOR OFF.
endif.
endloop.

Former Member
0 Kudos

hi

data line_color(4) type c.

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • Set layout field for row attributes(i.e. color)

gd_layout-info_fieldname = 'LINE_COLOR'.

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

<b>sample code to change colour</b>

form data_retrieval.

data: ld_color(1) type c.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

*Populate field with color attributes

loop at it_ekko into wa_ekko.

  • Populate color variable with colour properties

  • Char 1 = C (This is a color property)

  • Char 2 = 3 (Color codes: 1 - 7)

  • Char 3 = Intensified on/off ( 1 or 0 )

  • Char 4 = Inverse display on/off ( 1 or 0 )

  • i.e. wa_ekko-line_color = 'C410'

ld_color = ld_color + 1.

  • Only 7 colours so need to reset color value

if ld_color = 8.

ld_color = 1.

endif.

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

  • wa_ekko-line_color = 'C410'.

modify it_ekko from wa_ekko.

endloop.

endform. " DATA

regards

ravish

<b>plz reward points if helpful</b>

Former Member
0 Kudos

hey if its an ordinary report, then wirte the code in a simple format like this.

WRITE:/ itab-field1 COLOR 5 INTENSIFIED ON, itab-field2 COLOR 3 INTENSIFIED OFF.

Reward points if useful...

Cheers,

Sam