Color in ALV grid

Hi Experts,
I am using "REUSE_ALV_GRID_DISPLAY" to display output. I am not using oops.
Is there any possibility to show last row in different color.
And also let me know how to different color for one column in ALV grid display.
example:
COL1 | COL2 | COL3 |
=================
XXXX | 10 | 44 | 05 |
YYYY | 01 | 20 | 35 |
ZZZZZ | 05 | 10 | 20 |
I need to show in different color which are bold in the above output.
Thanks
Raghu

Hello
In order to colour columns you just need to set the colour (e.g. 'C510') in the fieldcatalog (LVC_S_FCAT-EMPHASIZE => SLIS-based ALV should be similar).
You may also have a look at threads
[ALV] Text in color and bold
styles
where you can find my sample report ZUS_SDN_ALV_CELL_STYLE_2 demonstrating what kind of color/style effects are possible in ALV grids.
Regards
  Uwe

Similar Messages

  • How to switch off column coloring of alv grid printouts?

    Hello World!
    Is there any possibility (a customizing option or a parameter) to switch off cell/column coloring of alv grid printouts?
    It is very useful to see colored columns in screens, but they are darkened in printouts. How to avoid it?
    Thanks and regards,
    Vladimir

    Hi,
    You can have different layouts for a ALV report and each layout the look and feel can be different.
    So, the manual activity is the user will have to switch to the B/W layout before printing. I am not sure if you have enabled the LAYOUT option for the user to change it by himself.
    I hope I am able to get across my point.
    If you are using OO ALV control, you can dynamically change the layout using set_frontend_layout  method. The user can also change the layout --
    choose Change layout or Settings ® Layout ® Change.
    The Change Layout dialog box shows you which columns are currently displayed and which additional columns can be displayed.
    Regards,
    Ravi
    Note - Please mark the helpful answers
    Message was edited by: Ravikumar Allampallam

  • To change the subtotals row color in ALV(Grid / List ) .

    I am trying to change the color of a row which gives the subtotal...in ALV report...
    but it is not working....
    I have used the following code but not getting where i m wrong
    I have u sed the following code wih the help of our forum only...
    <CODE>
    TYPE-POOLS: SLIS.
    *& Internal Table Delcaration
    DATA : BEGIN OF IT_SCALE OCCURS 0,
             DATUM LIKE ZSCALE-DATUM,
             MCOD1 LIKE ZSCALE-MCOD1,
             MATNR LIKE ZSCALE-MATNR,
             MAKTG LIKE ZSCALE-MAKTG,
             MEINS LIKE ZSCALE-MEINS,
             RATE LIKE ZSCALE-RATE,
             TOTAL LIKE ZSCALE-TOTAL,
             LI_COLOR(4),
           END OF IT_SCALE.
    DATA : INDEX LIKE SY-TABIX.
    *& ALV Data Declaration
    DATA: IT_FIELDCAT  TYPE SLIS_T_FIELDCAT_ALV.
    DATA: WA_FIELDCAT  LIKE LINE OF IT_FIELDCAT.
    DATA : T_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
    DATA : IT_EVENTS   TYPE SLIS_T_EVENT WITH HEADER LINE.
    DATA : G_SAVE(1)   TYPE C VALUE 'A',
           GX_SAVE(1)  TYPE C VALUE 'A',
           GX_VARIANT  LIKE DISVARIANT,
           G_VARIANT   LIKE DISVARIANT,
           GS_LAYOUT   TYPE SLIS_LAYOUT_ALV,
           T_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
           T_I_EVENT      TYPE SLIS_ALV_EVENT.
    DATA : L_LIST(105)    TYPE C,         "Store the Top-of-page headings
           L_DATEFROM(10) TYPE C,         "Store date in top-of-page
           L_DATETO(10)   TYPE C.         "Store date in top-of-page
    <code>
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM ALV_FIELDCAT.
      PERFORM GET_EVENTS.
      PERFORM SUB_COMMENT_BUILD USING T_LIST_TOP_OF_PAGE.
      PERFORM ALV_DISPLAY.
    FORM GET_DATA .
    DATA : LINE_COLOR.
      SELECT DATUM MCOD1 MATNR MAKTG MEINS RATE TOTAL
             FROM ZSCALE INTO CORRESPONDING FIELDS OF TABLE IT_SCALE
             WHERE DATUM IN S_DATE
               AND LIFNR IN S_LIFNR
               AND MATNR IN S_MATNR.
    loop at IT_SCALE.
      LINE_color = LINE_color + 2.
      if LINE_color < 7.
        LINE_color = 1.
      endif.
      concatenate 'C' lINE_color '00' into IT_SCALE-li_color.
      modify it_SCALE TRANSPORTING LI_COLOR.
    endloop.
    FORM ALV_FIELDCAT.
      DATA: COUNTER      TYPE I.
      COUNTER = COUNTER + 1.
      WA_FIELDCAT-COL_POS    = COUNTER.
      WA_FIELDCAT-FIELDNAME  = 'DATUM'.
      WA_FIELDCAT-TABNAME    = 'IT_SCALE'.
      WA_FIELDCAT-SELTEXT_L  = 'Date'.
      WA_FIELDCAT-JUST       = 'C'.
      WA_FIELDCAT-NO_ZERO    = 'X'.
      APPEND WA_FIELDCAT TO IT_FIELDCAT.
      CLEAR WA_FIELDCAT.
    .endform.
    FORM ALV_DISPLAY .
    GS_LAYOUT-ZEBRA        = 'X'.
      GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      GS_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
    gS_layout-no_input          = 'X'.
      gS_layout-totals_text       = 'Totals'(201).
      gS_layout-subtotals_text = 'Subtotal'.
      IF IT_SCALE[] IS INITIAL.
        MESSAGE I001(38) WITH 'No Data to Display'.
      ELSE.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
       IS_LAYOUT                      = GS_LAYOUT
      IT_FIELDCAT                    = IT_FIELDCAT
       I_SAVE                         = G_SAVE
       IS_VARIANT                     = GX_VARIANT
      TABLES
        T_OUTTAB                       = IT_SCALE[].
      ENDIF.
    ENDFORM.                    " ALV_DISPLAY
    ThanX in Adavance....

    Hi Prasad,
    I provided some code snippets for you. Please go through.
    Hope this proves to be helpful to you.
    The steps for coloring a line i the grid is much the same as making a traffic light.
    To color a line the structure of the  table must include a  Char 4 field  for color properties
    TYPES: BEGIN OF st_sflight.
            INCLUDE STRUCTURE zsflight.
          Field for line color
    types:  line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    Loop trough the table to set the color properties of each line. The color properties field is
    Char 4 and the characters is set as follows:
    Char 1 = C = This is a color property
    Char 2 = 6 = Color code (1 - 7)
    Char 3 = Intensified on/of = 1 = on
    Char 4 = Inverse display = 0 = of
         LOOP AT gi_sflight INTO g_wa_sflight.
          IF g_wa_sflight-paymentsum < 100000.
            g_wa_sflight-line_color    = 'C610'.
          ENDIF.
          MODIFY gi_sflight FROM g_wa_sflight.
        ENDLOOP.
    Name of the color field
    gs_layout-info_fname = 'LINE_COLOR'.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
          EXPORTING i_structure_name = 'SFLIGHT'
                                 is_layout                = gs_layout
          CHANGING  it_outtab                 = gi_sflight.
    Heres another Example for you:
        & Report  Z_ALV_COLOURS                                              &
        & This report shows how to use colours in REUSE_ALV_GRID_DISPLAY     &
        & C = Colour        (all codes must start with 'C')                  &
        & X = Colour number (1-9)                                            &
        & Y = Intensified   (0 = off, 1 = on)                                &
        & Z = Inverse       (0 = off, 1 = on)                                &
        report  z_alv_colours.
        data count_1(1) type c.
    ALV definitions
        type-pools: slis.
        data i_fieldcat type slis_t_fieldcat_alv with header line.
        data i_layout   type slis_layout_alv.
        types: begin of t_alv,
              f1(4) type c,
              f2(15) type c,
              f3(4) type c,
              f4(4) type c,
              f5(4) type c,
              f6(4) type c,
              colour(4)   type c,
              coltab type slis_t_specialcol_alv,
        end of t_alv.
        data: i_alv type standard table of t_alv with header line.
        data l_alvcolor type slis_specialcol_alv.
        & create table entries for LINE colours                              &
        do 9 times.
          count_1 = sy-index.
          clear i_alv.
          concatenate 'C' count_1 '0' '0' into i_alv-f1.
          concatenate 'C' count_1 '0' '0' into i_alv-colour.
          i_alv-f2 = 'Line colour'.
          i_alv-f3 = 'X'.
          append i_alv.
    Intensified
          clear i_alv.
          concatenate 'C' count_1 '1' '0' into i_alv-f1.
          concatenate 'C' count_1 '1' '0' into i_alv-colour.
          i_alv-f2 = 'Line colour'.
          i_alv-f4 = 'X'.
          append i_alv.
    Inverse
          clear i_alv.
          concatenate 'C' count_1 '0' '1' into i_alv-f1.
          concatenate 'C' count_1 '0' '1' into i_alv-colour.
          i_alv-f2 = 'Line colour'.
          i_alv-f5 = 'X'.
          append i_alv.
    Intensified & Inverse
          clear i_alv.
          concatenate 'C' count_1 '1' '1' into i_alv-f1.
          concatenate 'C' count_1 '1' '1' into i_alv-colour.
          i_alv-f2 = 'Line colour'.
          i_alv-f6 = 'X'.
          append i_alv.
        enddo.
    create table entries for CELL colours
        do 9 times.
          count_1 = sy-index.
          concatenate 'C' count_1 '0' '0' into i_alv-f1.
          i_alv-f2 = 'Cell colour'.
          concatenate 'C' count_1 '0' '0' into i_alv-f3.
          concatenate 'C' count_1 '1' '0' into i_alv-f4.
          concatenate 'C' count_1 '0' '1' into i_alv-f5.
          concatenate 'C' count_1 '1' '1' into i_alv-f6.
          append i_alv.
        enddo.
        & Create table entries for CELL colours                              &
        loop at i_alv where f2 = 'Cell colour'.
    Colour cells
          clear l_alvcolor.
          l_alvcolor-fieldname = 'F3'.
          l_alvcolor-color-col = i_alv-f3+1(1).
          l_alvcolor-color-int = i_alv-f3+2(1).
          l_alvcolor-color-inv = i_alv-f3+3(1).
          l_alvcolor-nokeycol = 'X'.
          append l_alvcolor to i_alv-coltab.
          clear l_alvcolor.
          l_alvcolor-fieldname = 'F4'.
          l_alvcolor-color-col = i_alv-f4+1(1).
          l_alvcolor-color-int = i_alv-f4+2(1).
          l_alvcolor-color-inv = i_alv-f4+3(1).
          l_alvcolor-nokeycol = 'X'.
          append l_alvcolor to i_alv-coltab.
          clear l_alvcolor.
          l_alvcolor-fieldname = 'F5'.
          l_alvcolor-color-col = i_alv-f5+1(1).
          l_alvcolor-color-int = i_alv-f5+2(1).
          l_alvcolor-color-inv = i_alv-f5+3(1).
          l_alvcolor-nokeycol = 'X'.
          append l_alvcolor to i_alv-coltab.
          clear l_alvcolor.
          l_alvcolor-fieldname = 'F6'.
          l_alvcolor-color-col = i_alv-f6+1(1).
          l_alvcolor-color-int = i_alv-f6+2(1).
          l_alvcolor-color-inv = i_alv-f6+3(1).
          l_alvcolor-nokeycol = 'X'.
          append l_alvcolor to i_alv-coltab.
          modify i_alv.
        endloop.
        & Configure ALV settings                                             &
    Create field catalog
        perform create_field_catalog using 'F1'     'T_ALV' 'Colour name'.
        perform create_field_catalog using 'F2'     'T_ALV' 'Description'.
        perform create_field_catalog using 'F3'     'T_ALV' 'BaseColour'.
        perform create_field_catalog using 'F4'     'T_ALV' 'Intensified'.
        perform create_field_catalog using 'F5'     'T_ALV' 'Inverse'.
        perform create_field_catalog using 'F6'     'T_ALV' 'Both Inv/Int'.
        perform create_field_catalog using 'COLOUR' 'T_ALV' 'Colour'.
    Layout
        clear i_layout.
        i_layout-colwidth_optimize   = 'X'.
        i_layout-info_fieldname      = 'COLOUR'.   " for line colour
        i_layout-coltab_fieldname    = 'COLTAB'.   " for cell colour
        call function 'REUSE_ALV_GRID_DISPLAY'
          exporting
            i_callback_program      = sy-cprog
            i_callback_user_command = 'USER_COMMAND'
            is_layout               = i_layout
            it_fieldcat             = i_fieldcat[]
            i_default               = 'X'
            i_save                  = 'A'
          tables
            t_outtab                = i_alv.
        & Form  CREATE_FIELD_CATALOG                                          &
        form create_field_catalog using    p_fieldname
                                           p_tabname
                                           p_text.
          i_fieldcat-fieldname        = p_fieldname.
          i_fieldcat-tabname          = p_tabname.
          i_fieldcat-seltext_l        = p_text.
          append i_fieldcat.
        endform.                    " CREATE_FIELD_CATALOG
    For more information about Coloring in ALV, Please refer :
    Coloring Rows in ALV
    Hope this helps you in solving your issue.
    Please Reward Points if any of the above points are helpful to you.
    Regards,
    Kalyan Chakravarthy

  • Color in ALV grid output based on condition

    Hi,
    I have generated a ALV Grid output.
    I have a internal table ITAB1. It has 2 fields - field1 and field2.
    Now, my requirement is if field1 is 'X', the row should be colored in RED, else if field1 is 'Y', the row should be colored in GREEN.
    How can it be done?
    Thanks,
    Shivaa.........

    Hi,
    add another field in the internal table with the type of char04.
    use the code given below....
    DATA : begin of itab occurs 0,
                  field1(10) type c,
                  field2(10) type c,
                  color(4) type c,
              end of itab.
    " fetch records in itab..
    loop at itab.
      if itab-field1 = 'X'.
          itab-color = 'C700'.         " Trial and error to get the color you want...
      elseif itab-field1 = 'Y'.
          itab-color = 'C300'.         " Trial and error to get the color you want...
      endif.
    endloop.
      fs_fcat-fieldname = 'FIELD1'.
      fs_fcat-col_pos = 1.
      fs_fcat-coltext = 'FIRST FIELD'.
      APPEND fs_fcat TO t_fcat.
      fs_fcat-fieldname = 'FIELD2'.
      fs_fcat-col_pos = 2.
      fs_fcat-coltext = 'SECOND FIELD'.
      APPEND fs_fcat TO t_fcat.
        fs_layo-sel_mode = 'A'.
        fs_layo-INFO_FNAME = 'COLOR'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_callback_program    = sy_cprog
          is_layout_lvc         = fs_layo
          it_fieldcat_lvc       = t_fcat
        TABLES
          t_outtab              = itab
        EXCEPTIONS
          program_error         = 1
          OTHERS                = 2.
    This resolves you issue....
    Cheers,
    Siddarth

  • Check box color in alv grid

    Hi friends,
    My requirement is , i am displaying data in alv grid with check box,here i want when we select check box then that realated line should be appear in the Blue color,can any one support me , Thanku in advance

    Hi danish,
    Thanku for the reply,but i doesnt work ,can u observe this code and give me your suggestion eloborately.
      gwa_fldcat-col_pos       = 2.
      gwa_fldcat-fieldname     = 'CHK'.
      gwa_fldcat-tabname       = 'GT_FINAL'.
      gwa_fldcat-EMPHASIZE = 'C310'.
       gwa_fldcat-input        = 'X'.
      gwa_fldcat-edit          = 'X'.
      gwa_fldcat-checkbox      = 'X'.
      gwa_fldcat-just          = 'C'.
      gwa_fldcat-key           = 'X'.
      gwa_fldcat-outputlen     = 16.
      gwa_fldcat-seltext_l     = 'Selection'.
      APPEND gwa_fldcat TO git_fldcat.
      CLEAR gwa_fldcat.
    FORM build_catalog .
      gs_layout-colwidth_optimize = 'X'.
      gs_layout-zebra             = 'CHK'.
      gs_layout-info_fieldname = 'LINE_COLOR'.
    gs_layout-box_fieldname     = 'CHK'.
      gs_layout-box_tabname       =  'GT_FINAL-CHK'.
    ENDFORM.                    " BUILD_CATALOG
    *&      Form  USER
    FORM user USING lv_okcode   LIKE sy-ucomm
                           rs_selfield TYPE slis_selfield.
    assign the function code to variable v_okcode
      lv_okcode = sy-ucomm.
    CASE sy-ucomm.
    handle the code execution based on the function code encountered
      CASE lv_okcode.
    loop at gt_final where chk = 'X'.
      gt_final-line_color = 'C110' .
    endloop.
        WHEN 'EXECUTE'.
          PERFORM execute.
        WHEN 'SELECTALL'.
          PERFORM selectall.
        WHEN 'DESELCTALL'.
          PERFORM deselectall.
        WHEN 'ASCENDING'.
          PERFORM ascending.
        WHEN 'DESCENDING'.
          PERFORM descending.
      ENDCASE.
      PERFORM alv.
    ENDFORM.

  • Color in alv grid colum

    hello experts,
    i  want  color in my one colum in alv grid display
    pls help me on this
    thx in advance.
    points will be rewarded.

    hi,
    try this code.
    Its for coloring cell and column both....
    *& Report  ZALV_DS
    REPORT  zalv_ds LINE-SIZE 35.
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           marc.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
          werks LIKE marc-werks,
          mtart LIKE mara-mtart,
          matkl LIKE mara-matkl,
          meins LIKE mara-meins,
          ntgew LIKE mara-ntgew,
         rowcolor(4) TYPE c,
          cellcolors TYPE lvc_t_scol,
         END OF itab.
    DATA:t_fcat TYPE slis_t_fieldcat_alv,
         t_eve TYPE slis_t_event.
    DATA : st_layout TYPE slis_layout_alv.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr.  " no intervals no-extension.
    *PARAMETERS:mat LIKE mara-matnr.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_cata USING t_fcat.
      PERFORM build_event.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM display_data.
    *&      Form  build_cata
          text
         -->TEMP_FCAT  text
    FORM build_cata USING temp_fcat TYPE slis_t_fieldcat_alv.
      sy-tvar0 = sy-uname.
      WRITE sy-datum TO sy-tvar1.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      wa_fcat-fix_column = 'x'.
      wa_fcat-key = 'X'.               <b>"To color a column</b> 
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
      wa_fcat-key = ' '.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MTART'.
      wa_fcat-seltext_m = 'Type'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATKL'.
      wa_fcat-seltext_m = 'Group'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MEINS'.
      wa_fcat-seltext_m = 'Measurement Unit'.
      APPEND wa_fcat TO temp_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'NTGEW'.
      wa_fcat-seltext_m = 'Net Value'.
      APPEND wa_fcat TO temp_fcat.
    ENDFORM.                    "build_cata
    *&      Form  build_event
          text
    FORM build_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = t_eve
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "build_event
    *&      Form  data_retrieval
          text
    FORM data_retrieval.
      SELECT maramatnr  maramtart maramatkl marameins mara~ntgew
       maktmaktx  marcwerks
      INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt ON
      maramatnr = maktmatnr
      INNER JOIN marc ON
      maramatnr = marcmatnr
      WHERE mara~matnr IN mat.
      SORT itab BY matnr.
      DELETE ADJACENT DUPLICATES FROM itab.
    ENDFORM.                    "data_retrieval
    *&      Form  display_data
          text
    FORM display_data.
    *******************************For setting Cell Color*******************************************
      DATA ls_cellcolor TYPE lvc_s_scol .
      st_layout-coltab_fieldname = 'CELLCOLORS'.
      READ TABLE itab INDEX 5 .
      ls_cellcolor-fname = 'MATNR' .
      ls_cellcolor-color-col = '1' .
      ls_cellcolor-color-int = '1' .
      APPEND ls_cellcolor TO itab-cellcolors .
      MODIFY itab INDEX 5 .
    st_layout-colwidth_optimize = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = 'ZALV_DS'
          is_layout          = st_layout
          i_save             = 'A'
          it_fieldcat        = t_fcat
          it_events          = t_eve
        TABLES
          t_outtab           = itab
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "display_data

  • Setting Font Color and Bold Property in ALV Grid

    I have a requirement to set the font in particular ALV Cells  in red color.
    Also this font (text) has to be set to Bold.
    I know how to set cell coloring in ALV Grid, but have no idea regarding how to set font color.
    Could please give me an idea/code segment/suggestion.
    Thank You!

    Please refer this post
    Coloring of ROWS in ALV tree

  • Adding color to a row in alv grid not using object oriented.

    Hello Gurus.
    I want to display a row in  color in alv grid using normal alv,  not by using object oriented programming.
    I am having one of the field say spart ie division in internal table itab.
    The spart has values like 12 , 45, 67, 68 ,88 ,99.
    when ever spart is 12 i want to display that row in color format. Here this table is sorted by mblnr so if 1st record is 12 then may be 50 th record will be 12. so when where the record contains the value has 12 then that row should be displayed in color. So please tell me how to do it. Previously i posted the same question but i got is by using object oriented. so please tell me how to do it without using object oriented.
    Thanks for all the replies.

    Check this example code.
    report zrich_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.
    Regards,
    Rich Heilman

  • Setting cell color in ALV

    Hi All
    I would be greatful if someone could please help...
    I am still attempting to get cells painted within a WDA ALV grid display.
    I have tried to use the method stated in the WDA sap press book - but this method is for use with TABLE element and I am using a ViewContainerUIElement for my table. There are mentions of wonderful ways to color cells in a list display - but I cannot understand how this can be achieved. I currently have this working appart from the numeric numbers of the design being set into the relavant column cell.
    If anyone could help that would be great...
    Please see: http://picasaweb.google.co.uk/dave.alexander69/Pictures#5244800978549492338
       LOOP AT lt_zdata INTO ls_zdata.
            lv_index = sy-tabix.
    *       set column values
    *       loop at row data and set colour attributes of individual cells
            LOOP AT lt_columns ASSIGNING <fs_column>.
              lr_col_header = <fs_column>-r_column->get_header( ).
              lr_col_header->set_ddic_binding_field( ).
              CREATE OBJECT lr_input_field EXPORTING value_fieldname = <fs_column>-id.
              lr_column = lr_column_settings->get_column( <fs_column>-id ).
    *         for the date columns only...
              IF <fs_column>-id(4) = 'CELL'.
    *           get and set column dates from select option user input
                READ TABLE lt_dates INTO ls_dates INDEX 1.
                IF lt_dates IS INITIAL.
                  lr_col_header->set_text( 'Date' ).
                ELSE.
                  ls_dates-low = ls_dates-low + lv_incr_date.
                  MOVE ls_dates-low+2(2) TO lv_for_col_date+6(2).   "Year
                  MOVE ls_dates-low+4(2) TO lv_for_col_date+3(2).   "Month
                  MOVE ls_dates-low+6(2) TO lv_for_col_date(2).     "Day
                  MOVE lv_for_col_date   TO lv_col_date.
                  lr_col_header->set_text( lv_col_date ).
                  lv_incr_date = lv_incr_date + 7.
                ENDIF.
                LOOP AT lt_orgdata_dates INTO ls_orgdata_dates
                  WHERE crew = ls_zdata-crew
                    AND position = ls_zdata-position
                    AND name = ls_zdata-person
                    AND trip_arr >= ls_dates-low
                    AND trip_dep <= ls_dates-low.
    *             column heading settings
                  lr_field = lr_table->if_salv_wd_field_settings~get_field( <fs_column>-id ).
                  lr_field->if_salv_wd_sort~set_sort_allowed( abap_false ).
    * trying to set cell variants ?@#??!!???
    *              lr_cv = lr_column->set_key( ls_zdata-variance ).
    *              lr_cv->set_editor( lr_input_field ).
    *              lr_cv->set_cell_design( value = '01').
    *              lr_column->add_cell_variant( lr_cv ).
    * current method of seeting the cell colors... (but puts value in cell!)
                  FIELD-SYMBOLS: <fs> TYPE data.
                  lr_column->set_cell_design_fieldname( value = <fs_column>-id ).
                  ASSIGN COMPONENT <fs_column>-id OF STRUCTURE ls_zdata TO <fs>.
                  WRITE: CL_WD_TABLE_COLUMN=>e_cell_design-one TO <fs>.
                  MODIFY lt_zdata FROM ls_zdata. " INDEX lv_index.
                ENDLOOP.
              ENDIF.
    Kind Regards
    Dave Alexander

    Hi check this code to set cell colors for ALV grid.
    Take a context attribute with type WDUI_TABLE_CELL_DESIGN.
    Here i am populating colors based on some condition.Check the loop of the internal table.
    method get_flight_details .
    data:node_flights type ref to if_wd_context_node,
         it_flights type sflight_tab1,
         ls_flights type sflight,
         it_final type   if_componentcontroller=>elements_flights,
         ls_final type   if_componentcontroller=>element_flights.
        select * from sflight into table it_flights
    up to 100 rows.
        node_flights = wd_context->get_child_node( 'FLIGHTS' ).
        loop at it_flights into ls_flights.
           move-corresponding ls_flights to ls_final.
           if ls_final-price = '185.00'.
              ls_final-readonly = abap_true.
              ls_final-celldesign =
    cl_wd_table_column=>e_cell_design-badvalue_light.
           else.
              ls_final-readonly = ' '.
              ls_final-celldesign =
    cl_wd_table_column=>e_cell_design-goodvalue_light.
           endif.
           append ls_final to it_final.
        endloop.
        node_flights->bind_table(
            new_items            = it_final
            set_initial_elements = abap_true
    *        INDEX                = INDEX
    data: l_ref_cmp_usage type ref to if_wd_component_usage.
    l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
    if l_ref_cmp_usage->has_active_component( ) is initial.
       l_ref_cmp_usage->create_component( ).
    endif.
    data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
    l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
       data:
         l_value type ref to cl_salv_wd_config_table.
       l_value = l_ref_interfacecontroller->get_model(
    * Make Price column editable
    data:l_column type ref to cl_salv_wd_column,
          l_column1 type ref to cl_salv_wd_column,
          lr_input type ref to cl_salv_wd_uie_input_field,
          l_input1 type ref to cl_salv_wd_uie_input_field.
    l_column = l_value->if_salv_wd_column_settings~get_column( 'PRICE' ).
    create object lr_input
      exporting
        value_fieldname = 'PRICE'
    l_column->set_cell_editor( value = lr_input ).
    * to make some cells non editable
    lr_input->set_read_only_fieldname( value = 'READONLY' ).
    l_value->if_salv_wd_column_settings~delete_column( id = 'READONLY'   )
    *Set the table Editable
    l_value->if_salv_wd_table_settings~set_read_only( value = abap_false ).
    *Give colors to cells
    l_column1 = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).
    l_column1->set_cell_design_fieldname( value = 'CELLDESIGN'  ).
    l_value->if_salv_wd_column_settings~delete_column( id = 'CELLDESIGN' )
    endmethod.
    Thanks
    Suman

  • Color change of a field  in ALV Grid Control

    Hi,
    One small help needed....
    My req is explained below:
    I have 3 fields empno, ename and deptno. and the records of these fields would be displayed in ALV grid control.
    When I hover the mouse on ename field, the color of the complete field should change to other color, say "RED".
    How do I get this. Are there any Mouse events in SAP?
    Kalyan

    Hi,
    Once i changed the color of a field in a alv (not grid alv), i suspose that the same in alv grid. Also i used an mouse event.
    To manage the color:
    TYPE-POOLS : SLIS, and check this type:  SLIS_T_SPECIALCOL_ALV.
    when you call the function to display the alv, there is a parameter in which you should pass an internal table that references the type  SLIS_T_SPECIALCOL_ALV.
    To manage the mouse:
    1.- You should add the event user command:
    for example:
    DATA: I_EVENT TYPE SLIS_ALV_EVENT.
    Llamo al la función que obtiene los eventos validos para el ALV
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE     = 0
           IMPORTING
                ET_EVENTS       = P_EVENTS
           EXCEPTIONS
                LIST_TYPE_WRONG = 1
                OTHERS          = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
      agrega evento user command
        READ TABLE P_EVENTS INTO I_EVENT
          WITH KEY NAME = SLIS_EV_USER_COMMAND.
        IF SY-SUBRC EQ 0.
          I_EVENT-FORM  = SLIS_EV_USER_COMMAND.
          MODIFY P_EVENTS FROM I_EVENT INDEX SY-TABIX.
        ENDIF.
      ENDIF.
    2.- you work with the user command event:
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD .
      CASE R_UCOMM.
        WHEN C_DOBLE_CLICK.
        here you do the things that you need when the mouse *     bottom it's pressed
          PERFORM xxxxxxx.
      ENDCASE.
    ENDFORM.
    3.- you can change the form of the mouse, but i don't remember exactly how to do that... try to check that, it's helpfull in order to display the fields that can execute a funtion in your alv.
    I hope this help you, and sorry for my english.
    Albio.-

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

  • Color a specific row in ALV GRID display when user clicks on that row

    hi
    i have the entire code ready of how to check the line selected by the user and also to color that line but after settings those parameters
    for to refresh the GRID so that the row apppears coloured .plz reply soon.... points will be awarded.....
    wat i have done is
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       i_callback_program                 = i_repid
       i_callback_user_command           = 'USER_COMMAND'
       is_layout                         = it_layout
       it_fieldcat                       = int_fieldcat
      TABLES
           t_outtab                          = int
      EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
    to display the GRID then when user clicks on any row this module gets called
       FORM user_command USING r_ucomm TYPE sy-ucomm
                               rs_selfield TYPE slis_selfield.
         READ TABLE int INDEX rs_selfield-tabindex.
         int-rowcolor = 'C410'.
         MODIFY  int INDEX rs_selfield-tabindex TRANSPORTING rowcolor.
         it_layout-info_fieldname = 'ROWCOLOR'.
    then  again i call 'REUSE_ALV_GRID_DISPLAY'
    to display the GRID with the user selected line colored . the problem with this is when u go back from this screen u go to the previously displayed grid ....... whihc i dont want .....
       ENDFORM.                    "user_command

    Hi,
    By using following code,you can set the colors for each row,
    Change this based on your requirement.
    TABLES VBAK.
    TYPE-POOLS SLIS.
    Data Declaration
    TYPES: BEGIN OF T_VBAK,
          VBELN TYPE VBAK-VBELN,
          ERDAT TYPE VBAK-ERDAT,
          ERNAM TYPE VBAK-ERNAM,
          AUDAT TYPE VBAK-AUDAT,
          VBTYP TYPE VBAK-VBTYP,
          NETWR TYPE VBAK-NETWR,
          VKORG TYPE VBAK-VKORG,
          VKGRP TYPE VBAK-VKGRP,
          LINE_COLOR(4) TYPE C,
          END OF T_VBAK.
    DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,
          WA_VBAK TYPE T_VBAK.
    ALV Data Declaration
    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
          GD_REPID TYPE SY-REPID.
    START-OF-SELECTION.
    PERFORM DATA_RETRIEVAL.
    PERFORM BLD_FLDCAT.
    PERFORM BLD_LAYOUT.
    PERFORM DISPLAY_ALV_REPORT.
    Build Field Catalog for ALV Report
    FORM BLD_FLDCAT.
    FLDCAT-FIELDNAME = 'VBELN'.
    FLDCAT-SELTEXT_M = 'Sales Document'.
    FLDCAT-COL_POS = 0.
    *FLDCAT-EMPHASIZE = 'C411'.
    FLDCAT-OUTPUTLEN = 20.
    FLDCAT-KEY = 'X'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'ERDAT'.
    FLDCAT-SELTEXT_L = 'Record Date created'.
    FLDCAT-COL_POS = 1.
    FLDCAT-KEY = 'X'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'ERNAM'.
    FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'AUDAT'.
    FLDCAT-SELTEXT_M = 'Document Date'.
    FLDCAT-COL_POS = 3.
    FLDCAT-EMPHASIZE = 'C110'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'VBTYP'.
    FLDCAT-SELTEXT_L = 'SD Document category'.
    FLDCAT-COL_POS = 4.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'NETWR'.
    FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.
    FLDCAT-COL_POS = 5.
    FLDCAT-OUTPUTLEN = 60.
    FLDCAT-DO_SUM = 'X'.
    FLDCAT-DATATYPE = 'CURR'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'VKORG'.
    FLDCAT-SELTEXT_L = 'Sales Organization'.
    FLDCAT-COL_POS = 6.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    FLDCAT-FIELDNAME = 'VKGRP'.
    FLDCAT-SELTEXT_M = 'Sales Group'.
    FLDCAT-COL_POS = 7.
    FLDCAT-EMPHASIZE = 'C801'.
    APPEND FLDCAT TO FLDCAT.
    CLEAR FLDCAT.
    ENDFORM.
    Build Layout for ALV Grid Report
    FORM BLD_LAYOUT.
    GD_LAYOUT-NO_INPUT = 'X'.
    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
    GD_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
    GD_LAYOUT-CONFIRMATION_PROMPT = 'X'.  “ This asks the confirmation before leaving the screen.
    ENDFORM.
    Display report using ALV grid
    FORM DISPLAY_ALV_REPORT.
    GD_REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = GD_REPID
       IS_LAYOUT                         = GD_LAYOUT
       I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
       I_GRID_TITLE                      = 'SALES DOCUMENT HEADER'
       IT_FIELDCAT                       = FLDCAT[]
       I_SAVE                            = 'X'
      TABLES
        T_OUTTAB                          = IT_VBAK
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    Retrieve data from VBAK table and populate itab IT_VBAK
    FORM DATA_RETRIEVAL.
    DATA LD_COLOR(1) TYPE C.
    SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG
    UP TO 20 ROWS
    FROM VBAK
    INTO TABLE IT_VBAK.
    LOOP AT IT_VBAK INTO WA_VBAK.
    LD_COLOR = LD_COLOR + 1.
    IF LD_COLOR = 8.
      LD_COLOR = 1.
    ENDIF.
    CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.
    MODIFY IT_VBAK FROM WA_VBAK.
    ENDLOOP.
    ENDFORM.
    FORM TOP_OF_PAGE.
    DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
          W_HEADER TYPE SLIS_LISTHEADER.
    W_HEADER-TYP = 'H'.
    W_HEADER-INFO = 'WELCOME HEADER LIST'.
    APPEND W_HEADER TO T_HEADER.
    W_HEADER-TYP = 'S'.
    W_HEADER-KEY = 'REPORT:'.
    W_HEADER-INFO = SY-REPID.
    APPEND W_HEADER TO T_HEADER.
    W_HEADER-TYP = 'S'.
    W_HEADER-KEY = 'DATE:'.
    CONCATENATE SY-DATUM6(2) ' / ' SY-DATUM4(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.
    APPEND W_HEADER TO T_HEADER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = T_HEADER
    ENDFORM.
    Reward points,if it is useful.
    Thanks,
    chandu.

  • How to color a row in ALV grid display

    Hi,
    A few rows in the output of ALV grid display should be shown in different color.How can I achieve this?

    Hi,
    Try out this code
    DATA : BEGIN OF G_T_CASH OCCURS 0,
           PARTICULARS TYPE CHAR120,
           AMOUNT1 TYPE CHAR20,
           AMOUNT2 TYPE CHAR20,
           AMOUNT3 TYPE CHAR20,    
           ROW_COLOR TYPE CHAR4,----
    add this in the internal table for alv
          END OF G_T_CASH.
      CLEAR G_WA_CASH.
      G_WA_CASH-PARTICULARS = 'Opening Cash Balance'.
      G_WA_CASH-AMOUNT1 = G_DMBTR.
      G_WA_CASH-AMOUNT2 = ''.
      G_WA_CASH-AMOUNT3 = ''.
    while appending other values also add the following code
      G_WA_CASH-ROW_COLOR = 'C200'.----- C200 depicts light gray color
      APPEND G_WA_CASH TO G_T_CASH.
    add the following code in layout
    MOVE 'ROW_COLOR' TO WA_LS_LAYOUT-INFO_FIELDNAME.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_BYPASSING_BUFFER = ' '
          I_SAVE             = 'A'
        I_CALLBACK_PROGRAM                = SY-REPID
      I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
       I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         IS_LAYOUT                        = WA_LS_LAYOUT
         IT_FIELDCAT                      = G_T_CATALOG
         IT_EVENTS                         = GT_EVENTS
         TABLES
           T_OUTTAB                       = G_T_CASH[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Let me know if the problem still persist.
    Regards,
    Janaki

  • Color a row with ALV GRID

    Hi my friends,
    I have written a small ALV Grid where some rows should be colored, dependend on their status in a table. But it's not working and I can't find out, why it is not working. I've already studied all the topics in this forum, which are related to 'row color alv grid', but I can't find the mistake in my code. Is anyone able to find out what is wrong here?
    Thanks a lot for your help!
    *& Report  /BMC_TST_SHOWLOG
    REPORT  /BMC_TST_SHOWLOG.
    TYPES: BEGIN OF log_table.
      TYPES:  log_level TYPE /bmc_log_message,
              cr_date TYPE /bmc_cr_date,
              message TYPE /bmc_log_message,
              linecolor(4) TYPE c.
    TYPES: END OF log_table.
    DATA: lt_log TYPE TABLE OF log_table with HEADER LINE,
          lt_log2 TYPE TABLE OF log_table with HEADER LINE,
          lt_log_list TYPE TABLE OF log_table,
          lt_line LIKE LINE OF lt_log_list,
          container_r TYPE REF TO cl_gui_custom_container,
          grid_r TYPE REF TO cl_gui_alv_grid,
          gc_custom_control_name TYPE scrfname VALUE 'CONTAINER_LOG',
          fieldcat_r TYPE lvc_t_fcat,
          layout_r TYPE lvc_s_layo,
          logA TYPE /bmc_log_level,
          logB TYPE /bmc_log_level,
          logC TYPE /bmc_log_level,
          logD TYPE /bmc_log_level,
          logE TYPE /bmc_log_level,
          ls_ct TYPE lvc_s_scol,
          ok_code LIKE sy-ucomm.
    *DATA BEGIN OF ls_log_list OCCURS 0.
    *DATA: log_level TYPE /bmc_log_message,
    *      cr_date TYPE /bmc_cr_date,
    *      message TYPE /bmc_log_message,
    *      rowcolor(4) TYPE c.
    *DATA END OF ls_log_list.
    *DATA: lt_log_list TYPE TABLE OF log_table.
    PARAMETERS: loglevlA  TYPE c AS CHECKBOX,
                loglevlB  TYPE c as CHECKBOX,
                loglevlC  TYPE c As CHECKBOX,
                loglevlD  TYPE c aS CHECKBOX,
                loglevlE  TYPE c AS CHECKBOX,
                dateA     TYPE /bmc_cr_date OBLIGATORY,
                dateB     TYPE /bmc_cr_date.
    CALL SCREEN 0200.
    MODULE user_command_0200 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          SET SCREEN 0.
          MESSAGE ID 'BC400' TYPE 'S' NUMBER '057'.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'DYNPRO200'.
      SET TITLEBAR 'D0200'.
    ENDMODULE.
    MODULE display_alv OUTPUT.
      PERFORM display_alv.
    ENDMODULE.
    FORM display_alv.
      IF grid_r IS INITIAL.
    *----Creating custom container instance
      CREATE OBJECT container_r
      EXPORTING
        container_name = gc_custom_control_name
      EXCEPTIONS
        cntl_error = 1
        cntl_system_error = 2
        create_error = 3
        lifetime_error = 4
        lifetime_dynpro_dynpro_link = 5
        others = 6.
        IF sy-subrc <> 0.
    *--Exception handling
        ENDIF.
    *----Creating ALV Grid instance
        CREATE OBJECT grid_r
        EXPORTING
          i_parent = container_r
        EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init = 2
          error_cntl_link = 3
          error_dp_create = 4
          others = 5.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          PERFORM get_log_data.
    *----Preparing field catalog.
          PERFORM prepare_field_catalog CHANGING fieldcat_r.
    *----Preparing layout structure
          PERFORM prepare_layout CHANGING layout_r.
    *----Here will be additional preparations
    *--e.g. initial sorting criteria, initial filtering criteria, excluding
    *--functions
          CALL METHOD grid_r->set_table_for_first_display
          EXPORTING
            is_layout = layout_r
          CHANGING
            it_outtab = lt_log2[]
            it_fieldcatalog = fieldcat_r
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error = 2
            too_many_lines = 3
            OTHERS = 4.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          ELSE.
            CALL METHOD grid_r->refresh_table_display
          EXCEPTIONS
            finished = 1
            OTHERS = 2.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
        ENDIF.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    ENDFORM.
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
        DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = '/BMC_LOG'
      CHANGING
        ct_fieldcat = pt_fieldcat[]
      EXCEPTIONS
        inconsistent_interface = 1
        program_error = 2
        OTHERS = 3.
      IF sy-subrc ne 0.
    *--Exception handling
      ENDIF.
      LOOP AT pt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'UUID'.
            ls_fcat-no_out = 'X'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'LOG_LEVEL'.
            ls_fcat-coltext = 'Meldungsart'.
            ls_fcat-outputlen = '25'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CR_DATE'.
            ls_fcat-coltext = 'Erstellungsdatum'.
            ls_fcat-outputlen = '20'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CR_TIME'.
            ls_fcat-no_out = 'X'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'MESSAGE'.
            ls_fcat-coltext = 'Nachricht'.
            ls_fcat-outputlen = '50'.
            MODIFY pt_fieldcat FROM ls_fcat.
        ENDCASE.
    *    CASE ls_fcat-value.
    *      WHEN '1'.
    *        ls_fcat-line_color = 'c100'.
    *    ENDCASE.
      ENDLOOP.
    ENDFORM.
    FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
      ps_layout-zebra = 'X'.
      ps_layout-grid_title = 'Log'.
      ps_layout-smalltitle = 'X'.
      ps_layout-info_fname = 'linecolor'.
    ENDFORM.
    FORM get_log_data.
      if loglevlA = 'X'.
        logA = '1'.
      ENDIF.
      if loglevlB = 'X'.
        logB = '2'.
      ENDIF.
      if loglevlC = 'X'.
        logC = '3'.
      ENDIF.
      if loglevlD = 'X'.
        logD = '4'.
      ENDIF.
      if loglevlE = 'X'.
        logE = '5'.
      ENDIF.
      IF dateB ne 0.
        SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
          OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA and cr_date <= dateB.
      ELSE.
        SELECT log_level cr_date message FROM /bmc_log INTO CORRESPONDING FIELDS OF TABLE lt_log_list WHERE log_level = logA
          OR log_level = logB OR log_level = logC OR log_level = logD OR log_level = logE and cr_date >= dateA.
      ENDIF.
    *    and cr_date >= dateA.
        SORT lt_log_list ASCENDING.
        LOOP AT lt_log_list INTO lt_line.
        IF lt_line-log_level = '1'.
          lt_line-log_level = 'Info'.
          lt_line-linecolor = 'C100'.
        ENDIF.
        IF lt_line-log_level = '2'.
          lt_line-log_level = 'Warning'.
          lt_line-linecolor = 'C200'.
        ENDIF.
        IF lt_line-log_level = '3'.
          lt_line-log_level = 'Error'.
          lt_line-linecolor = 'C300'.
        ENDIF.
        IF lt_line-log_level = '4'.
          lt_line-log_level = 'Debug'.
          lt_line-linecolor = 'C400'.
        ENDIF.
        IF lt_line-log_level = '5'.
          lt_line-log_level = 'Trace'.
          lt_line-linecolor = 'C500'.
        ENDIF.
        APPEND lt_line TO lt_log2.
        ENDLOOP.
    ENDFORM.
    SELECTION-SCREEN BEGIN OF SCREEN 0100 TITLE text-001 AS WINDOW.
    SELECTION-SCREEN END OF SCREEN 0100.

    > change to this
    >
    > <b>ps_layout-stylefname = 'LINECOLOR'.</b>
    >
    > sorry ignore the above line
    >
    > just debug and check what is happening
    >
    > Message was edited by:
    >         Chandrasekhar Jagarlamudi
    Hi,
    I've changed the line to <b>ps_layout-stylefname = 'LINECOLOR'.</b>, but then I'm getting a runtime error 'ASSIGN_TYPE_CONFLICT' in program 'SAPLSLVC in line 2975'...
    I don't have any idea what is causing that.

  • How to give colors to the top-of-page in ALV Grid

    How to give colors to the top-of-page in ALV Grid
    in table GT_LIST_TOP_OF_PAGE i am filling 3 rows ,i need 3 different colors to be displyed on top-of-page(one color to one row)
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    I_LOGO = 'ENJOYSAP_LOGO'
    IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
    please help mee

    HI Kranthi,
    Check out teh foll. link,
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    Hope this helps.

Maybe you are looking for