Color in ALV Column

hi to all,
I want to display ALV with diffrent colors in column.
Is it possible.
If so plz send me the sample code for guidance.
Thanks in advance.
Dharmishta

All info about colour code is in comment in the code.
Hope it will help a lot of you.
Report code
Code:
REPORT zcuitest_alv_07.
Use of colours in ALV grid (cell, line and column)            *
Table
TABLES : mara.
Type
TYPES : BEGIN OF ty_mara,
          matnr         LIKE mara-matnr,
          matkl         LIKE mara-matkl,
          counter(4)    TYPE n,
          free_text(15) TYPE c,
          color_line(4) TYPE c,           " Line color
          color_cell    TYPE lvc_t_scol,  " Cell color
END OF ty_mara.
Structures
DATA  : wa_mara     TYPE ty_mara,
        wa_fieldcat TYPE lvc_s_fcat,
        is_layout   TYPE lvc_s_layo,
        wa_color    TYPE lvc_s_scol.
Internal table
DATA : it_mara     TYPE STANDARD TABLE OF ty_mara,
       it_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,
       it_color    TYPE TABLE          OF lvc_s_scol.
Variables
DATA : okcode LIKE sy-ucomm,
       w_alv_grid          TYPE REF TO cl_gui_alv_grid,
       w_docking_container TYPE REF TO cl_gui_docking_container.
PARAMETERS : p_column AS CHECKBOX,
             p_line   AS CHECKBOX,
             p_cell   AS CHECKBOX.
START-OF-SELECTION.
  PERFORM get_data.
END-OF-SELECTION.
  PERFORM fill_catalog.
  PERFORM fill_layout.
  CALL SCREEN 2000.
*&      Module  status_2000  OUTPUT
      text
MODULE status_2000 OUTPUT.
  SET PF-STATUS '2000'.
ENDMODULE.                 " status_2000  OUTPUT
*&      Module  user_command_2000  INPUT
      text
MODULE user_command_2000 INPUT.
  DATA : w_okcode LIKE sy-ucomm.
  MOVE okcode TO w_okcode.
  CLEAR okcode.
  CASE w_okcode.
    WHEN 'BACK'.
      LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.                 " user_command_2000  INPUT
*&      Module  alv_grid  OUTPUT
      text
MODULE alv_grid OUTPUT.
  IF w_docking_container IS INITIAL.
    PERFORM create_objects.
    PERFORM display_alv_grid.
  ENDIF.
ENDMODULE.                 " alv_grid  OUTPUT
*&      Form  create_objects
      text
-->  p1        text
<--  p2        text
FORM create_objects.
Ratio must be included in [5..95]
  CREATE OBJECT w_docking_container
    EXPORTING
      ratio                       = 95
    EXCEPTIONS
      cntl_error                  = 1
      cntl_system_error           = 2
      create_error                = 3
      lifetime_error              = 4
      lifetime_dynpro_dynpro_link = 5
      others                      = 6.
  CREATE OBJECT w_alv_grid
    EXPORTING
      i_parent          = w_docking_container.
ENDFORM.                    " create_objects
*&      Form  display_alv_grid
      text
-->  p1        text
<--  p2        text
FORM display_alv_grid.
  CALL METHOD w_alv_grid->set_table_for_first_display
    EXPORTING
      is_layout                     = is_layout
    CHANGING
      it_outtab                     = it_mara
      it_fieldcatalog               = it_fieldcat
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
ENDFORM.                    " display_alv_grid
*&      Form  get_data
      text
-->  p1        text
<--  p2        text
FORM get_data.
  SELECT * FROM mara UP TO 5 ROWS.
    CLEAR : wa_mara-color_line, wa_mara-color_cell.
    MOVE-CORRESPONDING mara TO wa_mara.
    ADD 1                   TO wa_mara-counter.
    MOVE 'Blabla'           TO wa_mara-free_text.
    IF wa_mara-counter = '0002'
    AND p_line = 'X'.
Color line
      MOVE 'C410' TO wa_mara-color_line.
    ELSEIF wa_mara-counter = '0004'
    AND p_cell = 'X'.
Color cell
      MOVE 'FREE_TEXT' TO wa_color-fname.
      MOVE '5'         TO wa_color-color-col.
      MOVE '1'         TO wa_color-color-int.
      MOVE '1'         TO wa_color-color-inv.
      APPEND wa_color TO it_color.
      wa_mara-color_cell[] = it_color[].
    ENDIF.
    APPEND wa_mara TO it_mara.
  ENDSELECT.
ENDFORM.                    " get_data
*&      Form  fill_catalog
      text
-->  p1        text
<--  p2        text
FORM fill_catalog.
Colour code :                                                 *
Colour is a 4-char field where :                              *
             - 1st char = C (color property)                  *
             - 2nd char = color code (from 0 to 7)            *
                                 0 = background color         *
                                 1 = blue                     *
                                 2 = gray                     *
                                 3 = yellow                   *
                                 4 = blue/gray                *
                                 5 = green                    *
                                 6 = red                      *
                                 7 = orange                   *
             - 3rd char = intensified (0=off, 1=on)           *
             - 4th char = inverse display (0=off, 1=on)       *
Colour overwriting priority :                                 *
  1. Line                                                     *
  2. Cell                                                     *
  3. Column                                                   *
  DATA : w_position TYPE i VALUE '1'.
  CLEAR wa_fieldcat.
  MOVE w_position TO wa_fieldcat-col_pos.
  MOVE 'MATNR'    TO wa_fieldcat-fieldname.
  MOVE 'MARA'     TO wa_fieldcat-ref_table.
  MOVE 'MATNR'    TO wa_fieldcat-ref_field.
  APPEND wa_fieldcat TO it_fieldcat.
  ADD 1 TO w_position.
  CLEAR wa_fieldcat.
  MOVE w_position TO wa_fieldcat-col_pos.
  MOVE 'MATKL'    TO wa_fieldcat-fieldname.
  MOVE 'MARA'     TO wa_fieldcat-ref_table.
  MOVE 'MATKL'    TO wa_fieldcat-ref_field.
Color column
  IF p_column = 'X'.
    MOVE 'C610'     TO wa_fieldcat-emphasize.
  ENDIF.
  APPEND wa_fieldcat TO it_fieldcat.
  ADD 1 TO w_position.
  CLEAR wa_fieldcat.
  MOVE w_position TO wa_fieldcat-col_pos.
  MOVE 'COUNTER'  TO wa_fieldcat-fieldname.
  MOVE 'N'        TO wa_fieldcat-inttype.
  MOVE '4'        TO wa_fieldcat-intlen.
  MOVE 'Counter'  TO wa_fieldcat-coltext.
  APPEND wa_fieldcat TO it_fieldcat.
  ADD 1 TO w_position.
  CLEAR wa_fieldcat.
  MOVE w_position  TO wa_fieldcat-col_pos.
  MOVE 'FREE_TEXT' TO wa_fieldcat-fieldname.
  MOVE 'C'         TO wa_fieldcat-inttype.
  MOVE '20'        TO wa_fieldcat-intlen.
  MOVE 'Text'      TO wa_fieldcat-coltext.
  APPEND wa_fieldcat TO it_fieldcat.
ENDFORM.                    " fill_catalog
*&      Form  fill_layout
      text
-->  p1        text
<--  p2        text
FORM fill_layout.
Field that identify color line in internal table
  MOVE 'COLOR_LINE' TO is_layout-info_fname.
Field that identify cell color in inetrnal table
  MOVE 'COLOR_CELL' TO is_layout-ctab_fname.
ENDFORM.                    " fill_layout
Flow logic code
Code:
PROCESS BEFORE OUTPUT.
  MODULE status_2000.
  MODULE alv_grid.
PROCESS AFTER INPUT.
  MODULE user_command_2000.
plz reward points if useful...
regards,
Balaji

Similar Messages

  • Change color in alv column

    how do change color of a column in ALV.

    Hi
    The below abap program shows how to change the colour of individual ALV cells /fields. Only a small number of changes are required from a basic ALV grid which include adding a new field to ALV data declaration table(it_ekko), populating this field with the field name identifier and colour attributes and finally adding an entry to layout control work area. These changes are highlighted in bold below.
    REPORT  zdemo_alvgrid                 .
    REPORT  ZALV_CELLCOLOR.
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      CELLCOLOR TYPE LVC_T_SCOL,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
      perform data_retrieval.
      perform build_fieldcatalog.
      perform build_layout.
      perform set_cell_colours.
      perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you  more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
                  I.e. Field type may be required in-order for
                       the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    fieldcatalog-do_sum      = 'X'.
    fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      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).
      gd_LAYOUT-coltab_fieldname = 'CELLCOLOR'.  "CTAB_FNAME
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
          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
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
              it_events               = gt_events
              is_print                = gd_prntparams
                i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = it_ekko
           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_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
      select ebeln ebelp statu aedat matnr menge meins netpr peinh
       up to 10 rows
        from ekpo
        into CORRESPONDING FIELDS OF TABLE it_ekko.
    endform.                    " DATA_RETRIEVAL
    Form  TOP-OF-PAGE                                                 *
    ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
      data: t_header type slis_t_listheader,
            wa_header type slis_listheader,
            t_line like wa_header-info,
            ld_lines type i,
            ld_linesc(10) type c.
    Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_header.
               i_logo             = 'Z_LOGO'.
    endform.                    "top-of-page
    *&      Form  SET_CELL_COLOURS
          Set colour of individual ALV cell, field
    FORM SET_CELL_COLOURS .
      DATA: WA_CELLCOLOR TYPE LVC_S_SCOL.
      DATA: ld_index TYPE SY-TABIX.
      LOOP AT IT_EKKO into wa_ekko.
        LD_INDEX = SY-TABIX.
      Set colour of EBELN field to various colors based on sy-tabix value
        WA_CELLCOLOR-FNAME = 'EBELN'.
        WA_CELLCOLOR-COLOR-COL = sy-tabix.  "color code 1-7, if outside rage defaults to 7
        WA_CELLCOLOR-COLOR-INT = '1'.  "1 = Intensified on, 0 = Intensified off
        WA_CELLCOLOR-COLOR-INV = '0'.  "1 = text colour, 0 = background colour
        APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
        MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
      Set colour of NETPR field to color 4 if gt 0
        if wa_ekko-netpr gt 0.
          WA_CELLCOLOR-FNAME = 'NETPR'.
          WA_CELLCOLOR-COLOR-COL = 4.  "color code 1-7, if outside rage defaults to 7
          WA_CELLCOLOR-COLOR-INT = '0'.  "1 = Intensified on, 0 = Intensified off
          WA_CELLCOLOR-COLOR-INV = '0'.  "1 = text colour, 0 = background colour
          APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
          MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
        endif.
      Set colour of AEDAT field text to red(6)
        WA_CELLCOLOR-FNAME = 'AEDAT'.
        WA_CELLCOLOR-COLOR-COL = 6.  "color code 1-7, if outside rage defaults to 7
        WA_CELLCOLOR-COLOR-INT = '0'.  "1 = Intensified on, 0 = Intensified off
        WA_CELLCOLOR-COLOR-INV = '1'.  "1 = text colour, 0 = background colour
        APPEND WA_CELLCOLOR TO wa_ekko-CELLCOLOR.
        MODIFY it_ekko from wa_ekko INDEX ld_index TRANSPORTING CELLCOLOR.
      ENDLOOP.
    ENDFORM.                    " SET_CELL_COLOURS

  • How to set color to a column in ALV?

    Based on standard example BCALV_GRID_01 to modify,
    how to set color to a column???
    Moderator message: please search for available information/documentation before asking.
    Edited by: Thomas Zloch on Nov 6, 2010 9:43 AM

    Hi Sai ,
    you are posting the querry in the wrong forum ..
    but still I will answer ur querry...
    Incase you are not using the standard class to make your ALV then u can set the color of each column in the propertiesof column in the design time .
    Incase u see the colors in the design time but is not able to see the colors at the run time then you check the settings of the table I dont have system right now else I could have told you exact property...
    else if u r amking alv from the standard class then u will have to search the net for the method to color the same ..
    Thanks
    Sahil.

  • 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

  • How can I change the color of a column header?

    I need to change the color for some column header, how can I do it in webdynpro ABAP? Is it possible?

    hi ,
    i have used in alv....
    <font color="RED">text</font>
    but i think it is not possible to change the colour in table ui element.
    regards,
    sahai.s

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

  • Colors in ALV

    Hi How can i add colors in alv.
    Can you pls give a good example for this.
    thank you,
    Deepak

    HI,
    i am sending you a complete woking code ..you just run it and see the option in the output screen..select any of the check box and hit F8..and there it is.. you can modify the code to meet yur need
    Reward point if it satisfy your needs..
    REPORT ZOBJK1 .
    Use of colours in ALV grid (cell, line and column)            *
    Table
    tables : mara.
    Type
    types : begin of ty_mara,
              matnr         like mara-matnr,
              matkl         like mara-matkl,
              counter(4)    type n,
              free_text(15) type c,
              color_line(4) type c,           " Line color
              color_cell    type lvc_t_scol,  " Cell color
    end of ty_mara.
    Structures
    data  : wa_mara     type ty_mara,
            wa_fieldcat type lvc_s_fcat,
            is_layout   type lvc_s_layo,
            wa_color    type lvc_s_scol.
    Internal table
    data : it_mara     type standard table of ty_mara,
           it_fieldcat type standard table of lvc_s_fcat,
           it_color    type table          of lvc_s_scol.
    Variables
    data : okcode like sy-ucomm,
           w_alv_grid          type ref to cl_gui_alv_grid,
           w_docking_container type ref to cl_gui_docking_container.
    parameters : p_column as checkbox,
                 p_line   as checkbox,
                 p_cell   as checkbox.
    at selection-screen output.
      perform get_data.
      perform fill_catalog.
      if w_docking_container is initial.
        perform create_objects.
      endif.
    *&      Form  create_objects
    form create_objects.
      create object w_docking_container
        exporting
          ratio                       = 40
        exceptions
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          others                      = 6.
      create object w_alv_grid
        exporting
          i_parent          = w_docking_container.
    Field that identify color line in internal table
      move 'COLOR_LINE' to is_layout-info_fname.
    Field that identify cell color in inetrnal table
      move 'COLOR_CELL' to is_layout-ctab_fname.
      call method w_alv_grid->set_table_for_first_display
        exporting
          is_layout                     = is_layout
        changing
          it_outtab                     = it_mara
          it_fieldcatalog               = it_fieldcat
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
    endform.
    *&      Form  get_data
    form get_data.
      select * from mara up to 5 rows.
        clear : wa_mara-color_line, wa_mara-color_cell.
        move-corresponding mara to wa_mara.
        add 1                   to wa_mara-counter.
        move 'Blabla'           to wa_mara-free_text.
        if wa_mara-counter = '0002'
        and p_line = 'X'.
    Color line
          move 'C410' to wa_mara-color_line.
        elseif wa_mara-counter = '0004'
        and p_cell = 'X'.
    Color cell
          move 'FREE_TEXT' to wa_color-fname.
          move '6'         to wa_color-color-col.
          move '1'         to wa_color-color-int.
          move '1'         to wa_color-color-inv.
          append wa_color to it_color.
          wa_mara-color_cell[] = it_color[].
        endif.
        append wa_mara to it_mara.
      endselect.
    endform.
    *&      Form  fill_catalog
    form fill_catalog.
    Colour code :                                                 *
    Colour is a 4-char field where :                              *
                 - 1st char = C (color property)                  *
                 - 2nd char = color code (from 0 to 7)            *
                                     0 = background color         *
                                     1 = blue                     *
                                     2 = gray                     *
                                     3 = yellow                   *
                                     4 = blue/gray                *
                                     5 = green                    *
                                     6 = red                      *
                                     7 = orange                   *
                 - 3rd char = intensified (0=off, 1=on)           *
                 - 4th char = inverse display (0=off, 1=on)       *
    Colour overwriting priority :                                 *
      1. Line                                                     *
      2. Cell                                                     *
      3. Column                                                   *
      data : w_position type i value '1'.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'MATNR'    to wa_fieldcat-fieldname.
      move 'MARA'     to wa_fieldcat-ref_table.
      move 'MATNR'    to wa_fieldcat-ref_field.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'MATKL'    to wa_fieldcat-fieldname.
      move 'MARA'     to wa_fieldcat-ref_table.
      move 'MATKL'    to wa_fieldcat-ref_field.
    Color column
      if p_column = 'X'.
        move 'C610'     to wa_fieldcat-emphasize.
      endif.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'COUNTER'  to wa_fieldcat-fieldname.
      move 'N'        to wa_fieldcat-inttype.
      move '4'        to wa_fieldcat-intlen.
      move 'Counter'  to wa_fieldcat-coltext.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position  to wa_fieldcat-col_pos.
      move 'FREE_TEXT' to wa_fieldcat-fieldname.
      move 'C'         to wa_fieldcat-inttype.
      move '20'        to wa_fieldcat-intlen.
      move 'Text'      to wa_fieldcat-coltext.
      append wa_fieldcat to it_fieldcat.
    endform.

  • Fill colors to ALV cells

    Hi All,
    How can I display multiple colors to different cells in an ALV ?.
    Please help..
    Thanks in advance,
    sudeep v d..

    Hi Sudeep,
    In the below mentioned link a topic Color of ALV output, columns, and cells has been mentioned in the section '4.17.3 Appearance of ALV Output'.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aeaa1fefd706
    Best regards,
    Suresh

  • Change  row color on alv

    hi
    how can i change row color on alv.

    Hi
    thanks your answer  Uday Gubbala         
    i was examinated this link  [https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapWebDynproALV-ChangeCellColourbasedonContent]
    but i don't  do   this row  wd_this->m_alv_model = lo_value. error message : m_alv_model unknow.
    and this sample change column color but i want to row
    Thanks.

  • 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

  • Not able to color different rows with different colors in a column of table

    Hi,
    I am trying to to display different rows with different colors in a column of the table based on some decode condition.
    I have gone through the following threads :
    Can we colour the rows in the column of a table
    Changing Color of a value in a column
    This is what i have done :
    1.Added the following code to custom.xss(changed the name to Custom.xss as suggested in one of the above threads) --- in path ---- jdev\myhtml\OA_HTML\cabo\styles
    <style selector=".1">
    <includeStyle name="DefaultFontFamily"/>
    <property name="font-size">11pt</property>
    <property name="font-weight">Bolder</property>
    <property name="color">#008000</property>
    <property name="text-indent">3px</property>
    </style>
    <style selector=".2">
    <includeStyle name="DefaultFontFamily"/>
    <property name="font-size">11pt</property>
    <property name="font-weight">Bolder</property>
    <property name="color">#FFFF00</property>
    <property name="text-indent">3px</property>
    </style>
    2. Sql query of the VO is :
    select comments,role ,decode(role,'REQUESTER','1','2') Colorattr from xxat_sars_action_history where request_id = :1 and event_name = :2 and action_code <> 'PENDING'
    order by sequence_num desc
    3. Coded the following in the process request of the controller:
    OATableBean table = (OATableBean)webBean.findIndexedChildRecursive("CommentsTB");
    OAMessageStyledTextBean roleBN = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("role");
    OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(roleBN,"Colorattr");
    roleBN.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);
    where 1 and 2 form the colors ( i have even tried with 'Red' and 'Yellow'...as it was not working replaced with 1 and 2)
    4.The query returns data fine with corresponding 1 and 2 values.
    But different colors are not getting reflecting on to the UI.
    I am testing this on my local jdev.
    Please do let me know if i am missing something.
    Thanks ,
    Sushma.

    Any Clues please.....
    Thanks,
    Sushma.

  • Change color in ALV top of page

    Hi all,
    Can anyone tell me how (if it is possible) to change color in ALV top-of-page?
    Thank you in advance,
    Hagit

    Hi,
    It is not possible to change the color in ALV top of page.
    Thanks,
    Sriram Ponna.

  • Web dynpro for abap how to create a customize search help in alv column

       hi:
          Web dynpro for abap how to create a customize search help in alv column and put search help value into alv column?
          Are there specific examples ?
          thanks!!

    HI:
       I want to created a freely programed help which include date&time,and put help value to alv column.
      I have created a freely programed help in web dynpro for abpa application,I refer:
      **************** - WebDynpro for ABAP
      but have a problem!
       If you focus on the the input field in the first row, you get the value help
    However if  I go to the second row and focus on the same input field in this column, I don't get the value help:
    What is a good way to solve similar problems?
    thanks

  • Problem while exporting ALV column header to excel sheet.

    Hi,
    I am able to export an ALV grid details to an excel sheet. But the ALV column headers when exported to excel sheet are getting truncated.
    For eg: if my column header in ALV grid is displayed as 'Material' then the column header in excel sheet is 'Mater' only. Remaining portion is getting truncated.
    How can I view the entire column header text?
    Kindly assist.
    Thanks.

    I have the same problem with you, when user export to excel. I fixed it by using
    w_layo-colwidth_optimize = 'X'. <<<<<<<<<<<<This
    perform generate_fcat_reftab
        using 'PRUEFLOS' 'T_INPUT' '' '' 'Inspection Lot' 0.
    form generate_fcat_reftab  using    p_fieldname
                                        p_tabname
                                        p_ref_tabname
                                        p_ref_fieldname
                                        p_output_text
                                        p_output_lenght.
      clear w_fcat.
      w_fcat-fieldname = p_fieldname.
      w_fcat-tabname   = p_tabname.
      w_fcat-ref_fieldname = p_ref_fieldname.
      w_fcat-ref_tabname = p_ref_tabname.
      w_fcat-seltext_s = p_output_text.
      w_fcat-seltext_m = p_output_text.
      w_fcat-seltext_l = p_output_text.
      w_fcat-outputlen = p_output_lenght.
      w_fcat-ddictxt = 'L'. <<<<<<<<<<<<<<<<<<This
      append w_fcat to t_fcat.
    endform.

Maybe you are looking for

  • GENERATING ORACLE REPORT IN ADF

    Hi, i need to generate offer letter for student. an admin will need to generate offer letter of student bases on their intakeId, branchId, degId, and typeofferletter. currently im doing this in adf form. from here how to transfer the information in a

  • Can I create a photo album to embed in my website?

    I would like to create a photo album to embed in my website so visitors to the site could view it online. Can anyone tell me how, please? I am new to the photo publishing world...!) Thank you. Marion

  • Challenge: How to create an BMP Java Bean from a DBF Database??

    Hello guys.... This is my challenge and looking for some aim: I was asked to create an application that must read from an existing DBF Database of products (That is already used by an administrative system) an build a Price List in Real Time. The pro

  • How to create an installati​on CD using LV 8.0?

    How to create an installation CD using LV 8.0? I want to create an Installation CD so I can install the LV application to an user computer. Thanks a lot

  • Error while accessing ProcessRuntime mBean

    Hi, I am getting the following error when I am trying to call the method "getProcessInstances()" on ProcessRuntime MBean. [ m_process_runtime_mbean.getProcessInstances( query )).getInstanceIds() ); ] ----error--- [java] weblogic.management.Management