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: 

adding a color to row of a alv grid using function modules

Former Member
0 Kudos

Can anybody clearly explains me how to add a color to a row to an alv grid using function module reuse_alv_grid_display.

thanks in advance

regards

anil.

1 REPLY 1

anversha_s
Active Contributor
0 Kudos

hi,

chk this ample pgm

report zxyz_0004

no standard page heading.

type-pools slis.

data: fieldcat type slis_t_fieldcat_alv.

data: begin of imara occurs 0,

matnr type mara-matnr,

mtart type mara-mtart,

maktx type makt-maktx,

color_line(4) type c,

tcolor type slis_t_specialcol_alv, "cell

end of imara.

data: xcolor type slis_specialcol_alv.

start-of-selection.

perform get_data.

perform write_report.

************************************************************************

  • Get_Data

************************************************************************

form get_data.

imara-matnr = 'ABC'.

imara-mtart = 'ZCFG'.

imara-maktx = 'This is description for ABC'.

append imara.

imara-matnr = 'DEF'.

imara-mtart = 'ZCFG'.

imara-maktx = 'This is description for DEF'.

append imara.

imara-matnr = 'GHI'.

imara-mtart = 'ZCFG'.

imara-maktx = 'This is description for GHI'.

append imara.

loop at imara.

if sy-tabix = 1.

imara-color_line = 'C410'. " color line

endif.

if sy-tabix = 2. "color CELL

clear xcolor.

xcolor-fieldname = 'MTART'.

xcolor-color-col = '3'.

xcolor-color-int = '1'. "Intensified on/off

xcolor-color-inv = '0'.

append xcolor to imara-tcolor.

endif.

modify imara.

endloop.

endform.

************************************************************************

  • WRITE_REPORT

************************************************************************

form write_report.

data: layout type slis_layout_alv.

layout-coltab_fieldname = 'TCOLOR'.

layout-info_fieldname = 'COLOR_LINE'.

perform build_field_catalog.

  • CALL ABAP LIST VIEWER (ALV)

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

is_layout = layout

it_fieldcat = fieldcat

tables

t_outtab = imara.

endform.

************************************************************************

  • BUILD_FIELD_CATALOG

************************************************************************

form build_field_catalog.

data: fc_tmp type slis_t_fieldcat_alv with header line.

clear: fieldcat. refresh: fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Material Number'.

fc_tmp-fieldname = 'MATNR'.

fc_tmp-tabname = 'IMARA'.

fc_tmp-outputlen = '18'.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Material Type'.

fc_tmp-fieldname = 'MTART'.

fc_tmp-tabname = 'IMARA'.

fc_tmp-outputlen = '4'.

append fc_tmp to fieldcat.

clear: fc_tmp.

fc_tmp-reptext_ddic = 'Material'.

fc_tmp-fieldname = 'MAKTX'.

fc_tmp-tabname = 'IMARA'.

fc_tmp-outputlen = '40'.

fc_tmp-emphasize = 'C610'. " color column

append fc_tmp to fieldcat.

endform.

<b>anil , pls chk this link also.

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

very hlpful.</b>

rgds

anver

<b>pls mark points if ur issue solved</b>

Message was edited by: Anversha s

Message was edited by: Anversha s