Skip to Content
author's profile photo Former Member
Former Member

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Oct 14, 2006 at 06:07 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.