Skip to Content
author's profile photo
Former Member

Coloring particular line in ALV

Hi Experts,

I want to make color to parrticular line when it satisfies the condition in ALV report.

I am not using SLIS.

so is there any alternavite to clolor row on specific condition like...NETWR > 10000,

that row shold be in RED color.

Please give me Example of code.

Poins will be awarded soon.

Thanks,

Rohan

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • author's profile photo
    Former Member
    Posted on Aug 20, 2007 at 10:13 AM
    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 20, 2007 at 10:35 AM
    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 20, 2007 at 10:40 AM

    This code could be helpfull.

    
    TYPES: BEGIN OF types_vbrk,
           vbeln TYPE vbeln_vf,
           numki TYPE numki,
           bukrs TYPE bukrs,
           vkorg TYPE vkorg,
           erdat TYPE erdat,
           belnr TYPE belnr_d,
           budat TYPE budat,
           gjahr TYPE gjahr,
           newki TYPE numki,
           color TYPE char4,
           END OF types_vbrk.
    
    DATA: t_vbrk TYPE STANDARD TABLE OF types_vbrk.
    
    ............................
      if .....
       wa_vbrk-color = 'C611'.
    endif. 
       append wa_vbrk to t_vbrk.
       clear wa_vbrk.
       wa_layout-info_fname = 'COLOR'.
    ** Pass the Layout either to ALV generating FM or Method the line with color will ** be displayed in that color. 
    

    Hope that Helps

    Anirban M.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 21, 2007 at 10:17 AM

    Hi,

    Check this code,

    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,

    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.

    imara-matnr = 'JKL'.

    imara-mtart = 'ZCFG'.

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

    APPEND imara.

    DATA: color_code(1) TYPE n VALUE '1'.

    data: color_line(4) type c.

    LOOP AT imara.

    AT NEW matnr.

    CONCATENATE 'C' color_code '10' INTO color_line.

    color_code = color_code + 1.

    IF color_code = '8'.

    color_code = '1'.

    ENDIF.

    ENDAT.

    imara-color_line = color_line..

    MODIFY imara.

    ENDLOOP.

    ENDFORM. "get_data

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

    • WRITE_REPORT

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

    FORM write_report.

    DATA: layout TYPE slis_layout_alv.

    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. "write_report

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

    • 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'.

    APPEND fc_tmp TO fieldcat.

    ENDFORM.

    reward if helpful.

    regards,

    pritha.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 22, 2007 at 08:28 AM

    Dear Nimesh Master

    In stead of repeating the same question over and over maybe you could try to read the given usefull answers and solve your problem 😊

    Dirk.

    Add comment
    10|10000 characters needed characters exceeded