HOW TO CHANGE COLOR OF PARTICULAR CELL  IN ALV

I HAVE DISPLAYED A REPORT IN ALV
I WANT TO CHANGE THE COLOR OF VBELN FIELD  ON WHICH HOTSPOT IS ON?
HOW TO DO THIS?

Hi Lovleen,
Check out the code
*& Report  ZDEMO_ALVGRID                                               *
*& Example of a simple ALV Grid Report                                 *
*& The basic ALV grid, Enhanced to display each row in a different     *
*& colour                                                              *
REPORT  zdemo_alvgrid                 .
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,
  line_color(4) type c,     "Used to store row color attributes
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.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
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-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).
Set layout field for row attributes(i.e. color)
  gd_layout-info_fieldname =      'LINE_COLOR'.
gd_layout-totals_only        = 'X'.
gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                        "click(press f2)
gd_layout-zebra             = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text       = 'helllllo'.
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_XEVENTS
            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.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
  from ekpo
  into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
          i.e. wa_ekko-line_color = 'C410'
  ld_color = ld_color + 1.
Only 7 colours so need to reset color value
  if ld_color = 8.
    ld_color = 1.
  endif.
  concatenate 'C' ld_color '10' into wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
  modify it_ekko from wa_ekko.
endloop.
endform.                    " DATA_RETRIEVAL
Regards,
Chandru

Similar Messages

  • How to give color of particular cell in alv list display for dynamic table

    Dear Experts,
    i want to give color of a particular cell in alv list display (reuse_alv_list_display). Here i am passing data through dynamic table?

    Hi,
    Se this:
    DATA: lt_color    TYPE lvc_t_scol WITH HEADER LINE.
    DATA: BEGIN OF data_tab OCCURS 0.
             tabcolor     TYPE   lvc_t_scol,
          END OF data_tab.
    * Befone ALV call
      alv_layout-coltab_fieldname  = 'TABCOLOR'.
    * For each row in data_tab
    REFRESH: lt_color.
    CLEAR: lt_color.
    lt_color-color-col = 6.
    lt_color-color-int = 1.
    lt_color-fname = FIELD1'.
    APPEND lt_color.
    lt_color-color-col = 2.
    lt_color-color-int = 0.
    lt_color-fname = 'FIELD2'.
    APPEND lt_color.
    data_tab-tabcolor[] = lt_color[].
    append data_tab.
    Best regards,
    Leandro Mengue

  • How to color a particular cell in ALV.

    hi,
       I have a requirement where i need to select a particular cell of a column in ALV and upon selection , i need to change the color of the selected cell. I choose the color from the dropdown toolbar created by me.
    plz help, thanks.

       REPORT  ZTEST_DHR.
    TYPE-POOLS : SLIS.
    TYPES: BEGIN OF TY_MARA,
            FLAG  TYPE CHAR1,
            MATNR TYPE MARA-MATNR,
            ERSDA TYPE MARA-ERSDA,
            ERNAM TYPE MARA-ERNAM,
            WESCH TYPE MARA-WESCH,
            STYLE TYPE LVC_T_STYL,
            CELLCOLR TYPE LVC_T_SCOL,
          END OF TY_MARA.
    DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
    DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
           WA_MARA TYPE TY_MARA,
           WA_MARA1 TYPE TY_MARA.
    * for reuse alv grid display
    *DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
    *        WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
    *        WA_LAYOUT       TYPE SLIS_LAYOUT_ALV,
    *        GV_REPID      TYPE SY-REPID.
    *for LVC Display
    DATA : WA_SETTINGS TYPE LVC_S_GLAY.
    DATA : WA_LAYOUT TYPE LVC_S_LAYO.
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WA_FIELDCATALOG TYPE LVC_S_FCAT.
    DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
    DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
    START-OF-SELECTION.
      SELECT MATNR ERSDA ERNAM WESCH
        FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
      UP TO 10 ROWS.
    END-OF-SELECTION.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM BUILD_LAYOUT.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATALOG
    *       text
    FORM BUILD_FIELDCATALOG .
      WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
      WA_FIELDCATALOG-OUTPUTLEN =  6.
      WA_FIELDCATALOG-CHECKBOX  = 'X'.           "as checkbox
      WA_FIELDCATALOG-EDIT      = 'X'.
      WA_FIELDCATALOG-SELTEXT = 'Check box'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Mat no'.
    *  wa_fieldcatalog-input = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
      WA_FIELDCATALOG-OUTPUTLEN =  15.
      WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Quantity'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
    ENDFORM.                    "build_fieldcatalog
    *&      Form  BUILD_LAYOUT
    *       text
    FORM BUILD_LAYOUT .
      CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
    *  WA_LAYOUT-NO_INPUT          = LC_X.
      WA_LAYOUT-CWIDTH_OPT = LC_X.
      WA_LAYOUT-ZEBRA             = LC_X.
      WA_LAYOUT-STYLEFNAME = 'STYLE'.
      WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       text
    FORM DISPLAY_ALV_REPORT .
      LS_EDIT-FIELDNAME = 'FLAG'.
      LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
      INSERT LS_EDIT INTO TABLE LT_EDIT.
      INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
      LS_CELL_COLOR-FNAME = 'MATNR'.
      LS_CELL_COLOR-COLOR-COL = '7'.
      LS_CELL_COLOR-COLOR-INT = '1'.
      INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
      INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
      LOOP AT IT_MARA INTO WA_MARA.
        IF WA_MARA-ERSDA EQ '20080625'.
          MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
    *      I_INTERFACE_CHECK                 = ' '
    *      I_BYPASSING_BUFFER                =
    *      I_BUFFER_ACTIVE                   =
         I_CALLBACK_PROGRAM                = SY-REPID
         I_CALLBACK_PF_STATUS_SET          = 'F_SET_STATUS'
         I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
    *      I_CALLBACK_TOP_OF_PAGE            = ' '
    *      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *      I_CALLBACK_HTML_END_OF_LIST       = ' '
    *      I_STRUCTURE_NAME                  =
    *      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = 'Example of select and deselect'
    *      I_GRID_SETTINGS                   =
          IS_LAYOUT_LVC                     = WA_LAYOUT
         IT_FIELDCAT_LVC                   = IT_FIELDCATALOG
        TABLES
          T_OUTTAB                          = IT_MARA
    *    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.
    *  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *    EXPORTING
    *      I_CALLBACK_PROGRAM       = GV_REPID
    *      I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
    *      I_CALLBACK_USER_COMMAND  = 'F_USER_COMMAND'
    *      I_GRID_TITLE             = 'Example of select and deselect'
    *      I_GRID_SETTINGS          = WA_SETTINGS
    *      IS_LAYOUT                = WA_LAYOUT
    *      IT_FIELDCAT              = IT_FIELDCATALOG[]
    *    TABLES
    *      T_OUTTAB                 = IT_MARA.
    *  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  f_set_status
    *       text
    FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS1'.
    ENDFORM.                    " f_set_status
    *&      Form  f_user_command
    *       text
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
    * BREAK-POINT.
      CASE R_UCOMM.
        WHEN 'ASEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = 'X'.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DSEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = ' '.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DELETE'.
    *      BREAK-POINT.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
          DELETE IT_MARA
                   WHERE FLAG = 'X'.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'INSERT'.
          CLEAR WA_MARA.
          APPEND WA_MARA TO IT_MARA.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
        WHEN 'SAVEDB'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
    * CODE TO BE WRITTEN TO SAVE in DB just an insert statement
    *ENDLOOP.
      ENDCASE.
    ENDFORM.
       REPORT  ZTEST_DHR.
    TYPE-POOLS : SLIS.
    TYPES: BEGIN OF TY_MARA,
            FLAG  TYPE CHAR1,
            MATNR TYPE MARA-MATNR,
            ERSDA TYPE MARA-ERSDA,
            ERNAM TYPE MARA-ERNAM,
            WESCH TYPE MARA-WESCH,
            STYLE TYPE LVC_T_STYL,
            CELLCOLR TYPE LVC_T_SCOL,
          END OF TY_MARA.
    DATA : IT_MARA TYPE STANDARD TABLE OF TY_MARA.
    DATA : IT_MARA1 TYPE STANDARD TABLE OF TY_MARA,
           WA_MARA TYPE TY_MARA,
           WA_MARA1 TYPE TY_MARA.
    * for reuse alv grid display
    *DATA : IT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV,
    *        WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV,
    *        WA_LAYOUT       TYPE SLIS_LAYOUT_ALV,
    *        GV_REPID      TYPE SY-REPID.
    *for LVC Display
    DATA : WA_SETTINGS TYPE LVC_S_GLAY.
    DATA : WA_LAYOUT TYPE LVC_S_LAYO.
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT,
            WA_FIELDCATALOG TYPE LVC_S_FCAT.
    DATA REF1 TYPE REF TO CL_GUI_ALV_GRID.
    DATA: LS_EDIT TYPE LVC_S_STYL,
          LT_EDIT TYPE LVC_T_STYL.
    DATA : LS_CELL_COLOR TYPE LVC_S_SCOL.
    DATA : LT_CELL_COLOR TYPE LVC_T_SCOL.
    START-OF-SELECTION.
      SELECT MATNR ERSDA ERNAM WESCH
        FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA
      UP TO 10 ROWS.
    END-OF-SELECTION.
      PERFORM BUILD_FIELDCATALOG.
      PERFORM BUILD_LAYOUT.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATALOG
    *       text
    FORM BUILD_FIELDCATALOG .
      WA_FIELDCATALOG-FIELDNAME = 'FLAG'.
      WA_FIELDCATALOG-OUTPUTLEN =  6.
      WA_FIELDCATALOG-CHECKBOX  = 'X'.           "as checkbox
      WA_FIELDCATALOG-EDIT      = 'X'.
      WA_FIELDCATALOG-SELTEXT = 'Check box'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'MATNR'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Mat no'.
    *  wa_fieldcatalog-input = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERSDA'.
      WA_FIELDCATALOG-OUTPUTLEN =  15.
      WA_FIELDCATALOG-SELTEXT = 'Creation Date'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'ERNAM'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Creation Time'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
      WA_FIELDCATALOG-FIELDNAME = 'WESCH'.
      WA_FIELDCATALOG-OUTPUTLEN =  20.
      WA_FIELDCATALOG-SELTEXT = 'Quantity'.
    *  wa_fieldcatalog-input = 'X'.
    *  wa_fieldcatalog-edit = 'X'.
      APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG.
      CLEAR  WA_FIELDCATALOG.
    ENDFORM.                    "build_fieldcatalog
    *&      Form  BUILD_LAYOUT
    *       text
    FORM BUILD_LAYOUT .
      CONSTANTS : LC_X TYPE CHAR1 VALUE 'X'.
    *  WA_LAYOUT-NO_INPUT          = LC_X.
      WA_LAYOUT-CWIDTH_OPT = LC_X.
      WA_LAYOUT-ZEBRA             = LC_X.
      WA_LAYOUT-STYLEFNAME = 'STYLE'.
      WA_LAYOUT-CTAB_FNAME = 'CELLCOLR'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       text
    FORM DISPLAY_ALV_REPORT .
      LS_EDIT-FIELDNAME = 'FLAG'.
      LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
      INSERT LS_EDIT INTO TABLE LT_EDIT.
      INSERT LINES OF LT_EDIT INTO TABLE WA_MARA1-STYLE.
      LS_CELL_COLOR-FNAME = 'MATNR'.
      LS_CELL_COLOR-COLOR-COL = '7'.
      LS_CELL_COLOR-COLOR-INT = '1'.
      INSERT LS_CELL_COLOR into table LT_CELL_COLOR.
      INSERT LINES OF LT_CELL_COLOR into TABLE WA_MARA1-CELLCOLR.
      LOOP AT IT_MARA INTO WA_MARA.
        IF WA_MARA-ERSDA EQ '20080625'.
          MODIFY IT_MARA INDEX SY-TABIX FROM WA_MARA1 TRANSPORTING STYLE CELLCOLR.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
       EXPORTING
    *      I_INTERFACE_CHECK                 = ' '
    *      I_BYPASSING_BUFFER                =
    *      I_BUFFER_ACTIVE                   =
         I_CALLBACK_PROGRAM                = SY-REPID
         I_CALLBACK_PF_STATUS_SET          = 'F_SET_STATUS'
         I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
    *      I_CALLBACK_TOP_OF_PAGE            = ' '
    *      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *      I_CALLBACK_HTML_END_OF_LIST       = ' '
    *      I_STRUCTURE_NAME                  =
    *      I_BACKGROUND_ID                   = ' '
         I_GRID_TITLE                      = 'Example of select and deselect'
    *      I_GRID_SETTINGS                   =
          IS_LAYOUT_LVC                     = WA_LAYOUT
         IT_FIELDCAT_LVC                   = IT_FIELDCATALOG
        TABLES
          T_OUTTAB                          = IT_MARA
    *    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.
    *  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    *    EXPORTING
    *      I_CALLBACK_PROGRAM       = GV_REPID
    *      I_CALLBACK_PF_STATUS_SET = 'F_SET_STATUS'
    *      I_CALLBACK_USER_COMMAND  = 'F_USER_COMMAND'
    *      I_GRID_TITLE             = 'Example of select and deselect'
    *      I_GRID_SETTINGS          = WA_SETTINGS
    *      IS_LAYOUT                = WA_LAYOUT
    *      IT_FIELDCAT              = IT_FIELDCATALOG[]
    *    TABLES
    *      T_OUTTAB                 = IT_MARA.
    *  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  f_set_status
    *       text
    FORM F_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'STATUS1'.
    ENDFORM.                    " f_set_status
    *&      Form  f_user_command
    *       text
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            RS_SELFIELD TYPE SLIS_SELFIELD.
    * BREAK-POINT.
      CASE R_UCOMM.
        WHEN 'ASEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = 'X'.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DSEL'.
          LOOP AT IT_MARA INTO WA_MARA.
            WA_MARA-FLAG = ' '.
            MODIFY IT_MARA FROM WA_MARA.
          ENDLOOP.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'DELETE'.
    *      BREAK-POINT.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
          DELETE IT_MARA
                   WHERE FLAG = 'X'.
          RS_SELFIELD-REFRESH = 'X'.
        WHEN 'INSERT'.
          CLEAR WA_MARA.
          APPEND WA_MARA TO IT_MARA.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->REFRESH_TABLE_DISPLAY.
        WHEN 'SAVEDB'.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
            IMPORTING
              E_GRID = REF1.
          CALL METHOD REF1->CHECK_CHANGED_DATA.
    * CODE TO BE WRITTEN TO SAVE in DB just an insert statement
    *ENDLOOP.
      ENDCASE.
    ENDFORM.
    About Selecting a Color From Dropdown?  even i need to check for now this is the how u do cell color in alv

  • How to change color of cl_gui_alv_grid - cell ?

    Hi,
    i´m using cl_gui_alv_grid to display a table. In the table are colored cells.
      gs_layout-ctab_fname = 'COLINFO'.
          clear lcl_color.
          lcl_color-fname = 'DELIV_DATE_AB'.
          lcl_color-color-col = cl_gui_resources=>list_col_negative.
          lcl_color-color-int = 0.
          lcl_color-color-inv = 0.
          append lcl_color.
        wa_output-colinfo[] = lcl_color[].
        append wa_output to it_output.
    call method grid1->set_table_for_first_display
         exporting
    *    I_BYPASSING_BUFFER            =
    *    I_BUFFER_ACTIVE               =
    *    I_CONSISTENCY_CHECK           =
    *    I_STRUCTURE_NAME              =
         is_variant                    = gs_variant
         i_save                        = 'U'
    *    I_DEFAULT                     = 'X'
           is_layout                     = gs_layout
    *    IS_PRINT                      =
    *    IT_SPECIAL_GROUPS             =
         it_toolbar_excluding          = it_excluding
    *    IT_HYPERLINK                  =
    *    IT_ALV_GRAPHICS               =
    *    IT_EXCEPT_QINFO               =
        changing
          it_outtab                     = it_output
         it_fieldcatalog               = gt_fieldcat[]
    *    IT_SORT                       =
    *    IT_FILTER                     =
         exceptions
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
           others                        = 4.
    That all works fine!
    Now i want to change the color of the colored cell. I changed the table wa_output-colinfo in this way:
    read table wa_output-colinfo into lcl_color
                with key fname = 'DELIV_DATE_AB'.
              if sy-subrc = 0.
                clear lcl_color-color-col.
                lcl_color-color-int = 0.
                lcl_color-color-inv = 0.
                modify wa_output-colinfo from lcl_color index sy-tabix.
              endif.
    After that i call:
    ls_stable-row = 'X'.
    ls_stable-col = 'X'.
            call method grid1->refresh_table_display
               exporting
                 is_stable      = ls_stable
               exceptions
                 finished       = 1
                 others         = 2.
    But nothing happens with the colored cell!
    Any ideas?
    thanks&regards
    Dirk

    Hello Dirk
    As I said the problem is the time point when you call the REFRESH_TABLE_DISPLAY method.
    Please note that after handling an event usually PAI of the dynpro is NOT pass and therefore the list is not refreshed.
    The following sample report shows how to solve this problem:
    *& Report  ZUS_SDN_ALV_EDITABLE_1D
    * Flow logic of screen '100' (no elements, ok-code => gd_okcode ):
    **PROCESS BEFORE OUTPUT.
    **  MODULE STATUS_0100.
    **PROCESS AFTER INPUT.
    **  MODULE USER_COMMAND_0100.
    REPORT  zus_sdn_alv_editable_1d.
    TYPE-POOLS: abap.
    CONSTANTS:
      gc_tabname       TYPE tabname  VALUE 'KNB1'.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knb1.
    TYPES: cellcolor  TYPE lvc_t_scol.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    DATA:
      gs_outtab        TYPE ty_s_outtab,
      gt_outtab        TYPE ty_t_outtab.
    " Set new ok code in event handler: 'X' = yes, ELSE = no
    PARAMETER:
      p_newokc         AS CHECKBOX  DEFAULT ' '.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
            IMPORTING
              er_data_changed
              e_onf4
              e_onf4_before
              e_onf4_after
              e_ucomm
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_data_changed.
    *   define local data
        DATA: ld_answer(1)  TYPE c.
        check ( p_newokc = abap_true ).
        " Triggers PAI -> required for list refresh
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'REFRESH'
    *        IMPORTING
    *          rc       =
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT * FROM  (gc_tabname)
        INTO CORRESPONDING FIELDS OF TABLE gt_outtab UP TO 99 ROWS.
      PERFORM colour_cells.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          OTHERS   = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed FOR go_grid.
      " Triggers event DATA_CHANGED by pushing ENTER
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          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.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
          is_variant      = gs_variant
          i_save          = 'A'
        CHANGING
          it_outtab       = gt_outtab
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE:
    * Documenation of I_SAVE ("An Easy Reference for ALV Grid Control")
    *I_SAVE
    *Determines the options available to the user for saving a layout:
    *? 'X': global saving only
    *? 'U': user-specific saving only
    *? 'A': corresponds to 'X' and 'U'
    *? SPACE: no saving
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      go_grid->check_changed_data( ).
      CASE gd_okcode.
        WHEN 'BACK'  OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'REFRESH'.
          PERFORM colour_cells.
          CALL METHOD go_grid->refresh_table_display
    *        EXPORTING
    *          is_stable      =
    *          i_soft_refresh =
    *        EXCEPTIONS
    *          finished       = 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.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = gc_tabname
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ls_fcat-edit = abap_true.
      MODIFY gt_fcat FROM ls_fcat
          TRANSPORTING edit
        WHERE ( key NE abap_true ).
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_layout-zebra      = abap_true.
      gs_layout-ctab_fname = 'CELLCOLOR'.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  COLOUR_CELLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM colour_cells .
    * define local data
      DATA: ls_outtab   TYPE ty_s_outtab,
            ls_color    TYPE lvc_s_scol,
            ld_idx      TYPE i.
      LOOP AT gt_outtab INTO ls_outtab.
        ld_idx = syst-tabix.
        REFRESH: ls_outtab-cellcolor.
        IF ( ls_outtab-erdat+0(4) <= '2000' ).
          CLEAR: ls_color.
          ls_color-fname = 'ERDAT'.
          ls_color-color-col = cl_gui_resources=>list_col_negative.
          ls_color-color-int = 0.
          ls_color-color-inv = 0.
          APPEND ls_color TO ls_outtab-cellcolor.
        ENDIF.
        MODIFY gt_outtab FROM ls_outtab INDEX ld_idx.
      ENDLOOP.
    ENDFORM.                    " COLOUR_CELLS
    Regards
      Uwe

  • Color  a particular cell  in ALV

    Hi all,
      I am working with ALV using class cl_salv_table. i can colorize a particular colomn  using cl_salv_column_table->set_color method. I was able to do it. I have done it for an amount column. Now I want to show the amount in some other color if it is 0. Let me know whether that possibility is there or not. If yes, please let me know the corresponding class and method and how we can implement it.
    Thank u.

    Hi ,
    fill  emphasize of field catelog
    wa_fcat-emphasize = color_code eg 'C400' .
    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)      
    hope it helps .....

  • ALV color a particular cell on meeting certain condition

    hi all
         i am working with ALV , my requirement is to color a particular cell if condition mate.
    like .
       i have two fields in my ITAB  PlanedCost and ActualCost
    If ACTUALCOST is >= 80% of PLANEDCOST then
    ACTUALCOST cell must come in RED COLOR.
    how to do so .
    please guide me.

    Hi Rock,
            I tried a program to color a cell based on its value, but it is not working. Am pasting the code below and please can u exactly tell me what is the problem it.
    *& Report  ZSAPCOLV
    REPORT  zsapcolv.
    TABLES:mara.
    TYPES:BEGIN OF ty_mara,
          matnr TYPE mara-matnr,
          mtart TYPE mara-mtart,
          color1(4),
         END OF ty_mara.
    DATA:it_mara TYPE STANDARD TABLE OF ty_mara,
         it_color  TYPE TABLE  OF lvc_s_scol,
         wa_mara TYPE ty_mara,
         wa_color    TYPE lvc_s_scol,
         is_layout   TYPE lvc_s_layo.
    DATA: t_newtable TYPE REF TO data,
    t_newline  TYPE REF TO data.
    FIELD-SYMBOLS: <dyntab> TYPE STANDARD TABLE,
                   <wa_dyntab> TYPE ANY,
                   <gfs_wa> TYPE ANY.
    TYPES: BEGIN OF ty_cmara,
        matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
       tabcolor TYPE lvc_t_scol,
    END OF ty_cmara.   " Cell color
    DATA:it_cmara TYPE STANDARD TABLE OF ty_cmara.
    DATA:
          gr_table     TYPE REF TO cl_salv_table,
          gr_functions TYPE REF TO cl_salv_functions,
          gr_display   TYPE REF TO cl_salv_display_settings.
    DATA:   it_fcat TYPE lvc_t_fcat,
            wa_fcat TYPE lvc_s_fcat.
    DATA:it_fcat1 TYPE lvc_t_fcat, "with cell color
         it_fcat2 TYPE lvc_t_fcat,
    wa_fieldcat LIKE LINE OF it_fcat1,
    wa_cellcolors TYPE lvc_s_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:<t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    DATA:t_line  TYPE REF TO data .
    *-----design selection screen for plant and material type.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.
    SELECT-OPTIONS:
                     s_matnr     FOR mara-matnr.    "material type
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM fetch_data.
      PERFORM display_data.
    *&      Form  fetch_data
    FORM fetch_data .
      DATA:wa_cmara TYPE ty_cmara.
      DATA: ls_tabcolor TYPE lvc_s_scol.
      SELECT
    FROM mara
        INTO CORRESPONDING FIELDS OF TABLE it_mara WHERE matnr IN s_matnr.
      CHECK sy-subrc EQ 0.
      PERFORM build_catalog USING '1' 'MATNR' 'Material number' 'Material Number' ' ' '18'.
      PERFORM build_catalog USING '1' 'MTART' 'Material type' 'Material type' ' ' '10'.
      it_fcat1[] = it_fcat[].
       wa_fieldcat-fieldname = 'T_CELLCOLORS'.
       wa_fieldcat-ref_field = 'COLTAB'.
       wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
      APPEND wa_fieldcat TO it_fcat.
      cl_alv_table_create=>create_dynamic_table( EXPORTING it_fieldcatalog = it_fcat
                                                  IMPORTING ep_table = t_newtable ).
      ASSIGN t_newtable->* TO <dyntab>.
      CREATE DATA t_line LIKE LINE OF <dyntab>.
      ASSIGN t_line->* TO <gfs_wa>.
      PERFORM fill_data.
    ENDFORM.                    " fetch_data
    *&      Form  build_catalog
    FORM build_catalog  USING    p_pos TYPE lvc_colpos
                           p_field TYPE lvc_fname
                           p_reptext TYPE reptext
                           p_coltext TYPE coltext
                           p_check TYPE lvc_checkb
                           p_len TYPE lvc_outlen.
      wa_fcat-col_pos    = p_pos.
      wa_fcat-fieldname  = p_field.
      wa_fcat-reptext    = p_reptext.
      wa_fcat-checkbox   = p_check.
      wa_fcat-outputlen  = p_len.
      wa_fcat-emphasize = '6'.
      IF p_check = 'X'.
        wa_fcat-edit = 'X'.
      ENDIF.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    " catalog
    *&      Form  fill_data
    FORM fill_data .
      FIELD-SYMBOLS: <wa_tmp> TYPE ANY,
                     <v_fld> TYPE ANY,
                     <color> TYPE ANY,
                     <wa_color> TYPE lvc_s_scol.
      DATA: v_fld(20).
      DATA : lv_cnt TYPE i,
             t_newline1  type ref to data,
             lv_cnt1 TYPE i.
        FIELD-SYMBOLS: <ta_color> TYPE lvc_t_scol.
         DATA : field(15) TYPE c,
             col TYPE lvc_s_scol.
      create data t_newline1 LIKE <wa_color>.
      LOOP AT it_mara INTO wa_mara.
        lv_cnt1 = lv_cnt1 + 1.
        LOOP AT it_fcat INTO wa_fcat.
          UNASSIGN <wa_tmp>.
          ASSIGN COMPONENT wa_fcat-fieldname OF STRUCTURE <gfs_wa> TO <wa_tmp>.
          CONCATENATE 'WA_MARA-' wa_fcat-fieldname INTO v_fld.
          ASSIGN (v_fld) TO <v_fld>.
          CHECK sy-subrc EQ 0.
          IF <v_fld> = '000000000000000004'.
             col-fname = wa_fcat-fieldname.
             col-color-col = '5' .
             col-color-int = '0' .
              "ASSIGN COMPONENT wa_fcat-fieldname OF STRUCTURE <gfs_wa> TO <ta_color>.
               ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <gfs_wa> TO <ta_color> .
               APPEND col TO <ta_color>.
            <wa_tmp> = <v_fld>.
            lv_cnt = lv_cnt + 1.
          ENDIF.
          IF lv_cnt = 1.
            APPEND <gfs_wa> TO <dyntab>.
          ELSE.
            MODIFY <dyntab> INDEX lv_cnt1 FROM <gfs_wa>.
          ENDIF.
        ENDLOOP.
        lv_cnt = 0.
        CLEAR wa_mara.
      ENDLOOP.
    ENDFORM.                    " fill_data
    *&      Form  display_data
    FORM display_data .
    IF <dyntab> IS NOT INITIAL.
       LOOP AT <dyntab> INTO <gfs_wa>.
         ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gfs_wa> TO <w_field>.
         ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <gfs_wa> TO <t_cellcolors> .
         CLEAR wa_cellcolors.
        "wa_cellcolors-fname = 'MATNR'.
         "IF <w_field> = '000000000000000004'.
           "FORMAT INTENSIFIED COLOR = 6.
           wa_cellcolors-fname = 'MATNR'.
           wa_cellcolors-color-col = '7'.
           wa_cellcolors-color-int = '1'.
           "wa_cellcolors-color-inv = '1'.
           "wa_cellcolors-NOKEYCOL = ''.
          "ELSE.
          "wa_cellcolors-color-col = '5'.
        "ENDIF.
         APPEND wa_cellcolors TO <t_cellcolors>.
         MODIFY <dyntab> FROM <gfs_wa>.
       ENDLOOP.
      cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = <dyntab> ).
      gr_functions = gr_table->get_functions( ).
      gr_functions->set_all( abap_true ).
      gr_display = gr_table->get_display_settings( ).
      gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
      gr_display->set_list_header( 'MARA DATA' ).
      gr_table->display( ).
      "ENDIF.
    ENDFORM.                    " display_data

  • Color the Particular cell

    Hi Techies
    I have one req in which i need to color the Particular cell, Provide me the Logic for that in which only change filed should be highlight to a specific Color.
    I have alogic for color the whole column and Row, but i need to color only particular cell.
    Moderator message: vague, help not possible without asking return questions, what cells are we talking about, provide as much technical detail as possible when posting.
    Edited by: Thomas Zloch on Feb 15, 2012

    Thanks Edward for ur reply...
    But in Inventory In warehouse report they gave the total as in different color.How they done that?????
    Regards,
    Anitha

  • Coloring a Particular Cell

    Hi,
           Please find below the sample program in which tried to color a particular cell. But it is not applying the color. Please help me to resolve this issues.
    Thanks in Advance,
    Sunil Kumar
    *& Report  ZSAPCOLV
    REPORT  ZSAPCOLV.
    TABLES:mara.
    TYPES:BEGIN OF ty_mara,
          matnr TYPE mara-matnr,
          mtart TYPE mara-mtart,
         END OF ty_mara.
    DATA:it_mara TYPE STANDARD TABLE OF ty_mara,
         it_color  type table  of lvc_s_scol,
         wa_mara TYPE ty_mara,
         wa_color    type lvc_s_scol,
         is_layout   type lvc_s_layo.
    DATA: t_newtable TYPE REF TO data,
    t_newline  TYPE REF TO data.
    FIELD-SYMBOLS: <dyntab> TYPE STANDARD TABLE,
                   <wa_dyntab> TYPE ANY,
                   <gfs_wa> TYPE ANY.
    TYPES: BEGIN OF ty_cmara,
         matnr TYPE mara-matnr,
          mtart TYPE mara-mtart,
        tabcolor TYPE lvc_t_scol,
      END OF ty_cmara.   " Cell color
    DATA:it_cmara TYPE STANDARD TABLE OF ty_cmara.
    DATA:
          gr_table     TYPE REF TO cl_salv_table,
          gr_functions TYPE REF TO cl_salv_functions,
          gr_display   TYPE REF TO cl_salv_display_settings.
    DATA:   it_fcat TYPE lvc_t_fcat,
            wa_fcat TYPE lvc_s_fcat.
    DATA:it_fcat1 TYPE lvc_t_fcat, "with cell color
         it_fcat2 TYPE lvc_t_fcat,
    wa_fieldcat LIKE LINE OF it_fcat1,
    wa_cellcolors TYPE lvc_s_scol,
    wa_is_layout TYPE lvc_s_layo.
    FIELD-SYMBOLS:<t_cellcolors> TYPE lvc_t_scol,
    <w_field> TYPE ANY.
    DATA:t_line  TYPE REF TO data .
    *-----design selection screen for plant and material type.
    selection-screen begin of block b1 with frame title text-b01.
    select-options:
                     s_matnr     for mara-matnr.    "material type
    selection-screen end of block b1.
    START-OF-SELECTION.
      PERFORM fetch_data.
      PERFORM display_data.
    *&      Form  fetch_data
    FORM fetch_data .
    DATA:wa_cmara TYPE ty_cmara.
    DATA: ls_tabcolor TYPE lvc_s_scol.
      SELECT
    FROM mara
        INTO CORRESPONDING FIELDS OF TABLE it_mara where matnr in s_matnr.
      CHECK sy-subrc EQ 0.
      PERFORM build_catalog USING '1' 'MATNR' 'Material number' 'Material Number' ' ' '18'.
      PERFORM build_catalog USING '1' 'MTART' 'Material type' 'Material type' ' ' '10'.
      it_fcat1[] = it_fcat[].
       wa_fieldcat-fieldname = 'T_CELLCOLORS'.
       wa_fieldcat-ref_field = 'COLTAB'.
       wa_fieldcat-ref_table = 'CALENDAR_TYPE'.
      APPEND wa_fieldcat TO it_fcat.
      cl_alv_table_create=>create_dynamic_table( EXPORTING it_fieldcatalog = it_fcat
                                                  IMPORTING ep_table = t_newtable ).
      ASSIGN t_newtable->* TO <dyntab>.
      CREATE DATA t_line LIKE LINE OF <dyntab>.
      ASSIGN t_line->* TO <gfs_wa>.
      PERFORM fill_data.
    ENDFORM.                    " fetch_data
    *&      Form  build_catalog
    FORM build_catalog  USING    p_pos TYPE lvc_colpos
                           p_field TYPE lvc_fname
                           p_reptext TYPE reptext
                           p_coltext type coltext
                           p_check TYPE lvc_checkb
                           p_len TYPE lvc_outlen.
      wa_fcat-col_pos    = p_pos.
      wa_fcat-fieldname  = p_field.
      wa_fcat-reptext    = p_reptext.
      wa_fcat-checkbox   = p_check.
      wa_fcat-outputlen  = p_len.
      IF p_check = 'X'.
        wa_fcat-edit = 'X'.
      ENDIF.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    " catalog
    *&      Form  fill_data
    FORM fill_data .
      FIELD-SYMBOLS: <wa_tmp> TYPE ANY,
                     <v_fld> TYPE ANY,
                     <color> TYPE ANY.
      DATA: v_fld(20).
      DATA : lv_cnt TYPE i,
             lv_cnt1 TYPE i.
      DATA:wa_cmara TYPE ty_cmara.
      LOOP AT it_mara INTO wa_mara.
        lv_cnt1 = lv_cnt1 + 1.
        LOOP AT it_fcat INTO wa_fcat.
          UNASSIGN <wa_tmp>.
          ASSIGN COMPONENT wa_fcat-fieldname OF STRUCTURE <gfs_wa> TO <wa_tmp>.
          CONCATENATE 'WA_MARA-' wa_fcat-fieldname INTO v_fld.
          ASSIGN (v_fld) TO <v_fld>.
          CHECK sy-subrc EQ 0.
          <wa_tmp> = <v_fld>.
          lv_cnt = lv_cnt + 1.
          IF lv_cnt = 1.
            APPEND <gfs_wa> TO <dyntab>.
          ELSE.
            MODIFY <dyntab> INDEX lv_cnt1 FROM <gfs_wa>.
          ENDIF.
        ENDLOOP.
        lv_cnt = 0.
        CLEAR wa_mara.
      ENDLOOP.
    ENDFORM.                    " fill_data
    *&      Form  display_data
    FORM display_data .
      IF <dyntab> IS NOT INITIAL.
        LOOP AT <dyntab> INTO <gfs_wa>.
          ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gfs_wa> TO <w_field>.
          ASSIGN COMPONENT 'T_CELLCOLORS' OF STRUCTURE <gfs_wa> TO <t_cellcolors> .
          CLEAR wa_cellcolors.
         wa_cellcolors-fname = 'MATNR'.
          IF <w_field> = '000000000100000012'.
            wa_cellcolors-color-col = '6'.
            wa_cellcolors-color-int = '1'.
            wa_cellcolors-color-inv = '1'.
           ELSE.
           wa_cellcolors-color-col = '5'.
         ENDIF.
          APPEND wa_cellcolors TO <t_cellcolors>.
          MODIFY <dyntab> FROM <gfs_wa>.
        ENDLOOP.
        cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = <dyntab> ).
        gr_functions = gr_table->get_functions( ).
        gr_functions->set_all( abap_true ).
        gr_display = gr_table->get_display_settings( ).
        gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
        gr_display->set_list_header( 'MARA DATA' ).
        gr_table->display( ).
      ENDIF.
    ENDFORM.                    " display_data

    Hi Sunil,
    Coloring a cell is pretty simple.
    1.
    FORMAT COLOR 3 INTENSIFIED ON.
    WRITE:/15 FS_TABLE-FIELD1.
    FORMAT COLOR OFF.
    Color 3 which is Yellow, begins from 0 to last letter of FIELD1.
    To color up the entire row, you can mention
    FORMAT COLOR 3 INTENSIFIED ON.
    WRITE:/15(255) FS_TABLE-FIELD1.
    FORMAT COLOR OFF.
    2. Coloring a cell, carries a bit different method
    LOOP..
    WRITE:/ FS_TABLE-FIELD1 COLOR 3,
                 FS_TABLE-FIELD2-COLOR4.
    ENDLOOP.
    Hope this really helps you,
    Courtesy: Zahackson
    Edited by: Zahackson on Feb 6, 2009 10:25 AM

  • How to change colors of LCD/VFD controls from SGC-Tek?

    Hi Anybody got idea how to change colors of LCD/VFD controls from SGC-Tek?
    I have tried but could not. When I try to make myself a nest cluster of clusters of LEDs, I can change colours but I can't do the same thing with LCD/VFD controls.
    Please check at LCD/VFD controls
    Clement

    I suspect this repsonse is somewhat mis-leading, the code has no effect on the control other than setting its state, although the route is somewhat tedious for the mod.
    I would imagine that the control is set up so that the pixels didn't move around when they are being used as controls.
    There are nested groups and locks on the controls, which might make the ordering in the cluster easier to manage.
    The following should work....... ;-) it did for me
    Open  your own new VI
    Open the main LCD VI
    Open the Browse VI Hierachy
    Drag and drop the LCD VI onto your own diagram
    Create a cluster from the LCD VI's connector
    Now ungroup the clusters and unlock them (this is tedious) if you create your own then you could be more imaginative in the structure, I leave that for homework.
    Then import a new bitmap (gif) into the control
    Now update the modified contol back into the master control
    ........ Told you it could be done, but I am not sure the pain was worth it.
    BUT
    Try the alternative control..... with colour settings as well, ANY colour and even some size control.
    It was here http://members.lycos.co.uk/sgctek/

  • How to change colors of individual column bar in the same data series

    in mac numbers, how to change colors of individual column bar in the same data series. The entire column series gets selected in the column bars and cannot select to change colors of specifc bars.

    Hi Kiran,
    no its not possible through Theme editor also ,because these colors are coming from Compiler which u are using.
    Regards,
    Govindu

  • How to change colors in Auction monitor

    Hi Experts,
    Could you please help me on below requirement,
    In Auction Monitor , need different darker colors for tracking bids  because some colors cannot be seen on the screen.
    Could you please guide me how to change colors in Monitor.
    Thanks,
    Pavan.

    Hi Vinay.
    I would like to suggest a couple of references, quite similar to your requirement,
    [SDN - Reference for Different Colors in Single Graphical bar|About Different Colors in Single Graphical bar;
    [SDN - Reference for changing colors for graphs|Anyone used colors in VC?;
    [SAP HELP - Standard Reference for Assigning Colors to Parts of a Graph|http://help.sap.com/saphelp_nw04/helpdata/en/39/cca358576911d1896f0000e829fbbd/content.htm]
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • How to change color of a button for specific time interval in jsp

    How to change color of a button for specific time interval in jsp.
    Please help.
    Thanks in advance.

    This was driving me crazy, too--and the previous answers did not seem to work. I eventually found that if I click one of the data symbols in the graph in exactly the right spot (see below), it selects only the data symbols and not the line. I can tell this because the little selection dots will be around each data symbol, but no selection dots will be on the line between the data symbols - like the graphic in Yvan's answer. Then and only then will the color symbol in the tool bar show the color of the data symbol, instead of the color of the line. I believe that you then have to first click on the color swatch in the toolbar and then select your color (or choose Show Colors and select from the color tool). Just clicking a color in the crayon box, for example, did not seem to work unless I first clicked on the color swatch in the toolbar, then clicked Show Colors on that dropdown, and +only then+ clicked the crayon or whatever.
    _The right spot to click_ seems to be just above the exact center of the data symbol, at least for the diamond shape symbol that I prefer. Sometimes it takes several tries to hit the right spot. If I miss it, the whole line is selected, which is indicated by the little selection dots on the line, between the data symbols. When I click the right spot, those selection dots go away, leaving only the data symbols selected. Then I can change the color, as described above.
    I hope this works for you too.

  • How to change color in BEx Browser?

    Hello Friends,
    How to change color in BEx Browser?
    My browser shows all the report description with pink color. I want to change the color.
    Please let me know.
    Thanks in advance.

    Hello Bhavin,
    It seems the patches for BW Add-On are being kept pretty much in sync for 6.20 and 6.40 (i.e they seem to be released at around the same time, even that the patch level numbers are different).
    However, at BW Add-on Patch level 4 on a SAPgui640 machine, we didn't have the "pink font" problem.
    It may be that BW 3.5 Add-On patch 6 will have a similar effect for you - it may be worth trying.
    Here is the link to the BW3.50 patch 6... https://smpdl.sap-ag.de/~swdc/012002523100000108232005D/bw350_6-10001615.exe?_ACTION=DL_DIRECT
    The patch 6 referred to above is for the BW3.50 Add-On - the SAPgui patch is typically a different number (the 11 that you mention is the SAPgui patch level).
    Best regards,
    Pat M.

  • Coloring of Particular Cells in a dynamic internal table(field symbols)

    Hi,
         I have a requirement to introduce color into some particular cells in a dynamic internal table(Field symbol) based on some conditions.I know that color can be introduced at cell level in the case of static internal table.But, can anybody tell me whether it is possible to introduce color to particular cells in the dynamic internal table(Field Symbol) .Please suggest me on this issue.
    Thanks in advance,
    Rajesh

    Hi,
    This is the sample coding for the colour cell report.
    Kindly go through it. It will helps u.
    REPORT YMS_COLOURTEST .
    DATA: BEGIN OF TP OCCURS 10, ID, NR(8), TEXT(255), END OF TP.
    DATA: LENGTH TYPE I VALUE 8, " Length of list
    TESTSTRING(15) TYPE C VALUE '012345678901234',
    WIDTH TYPE I. " Width of list
    DATA: TXT_REPORT LIKE DOKHL-OBJECT.
    START-OF-SELECTION.
    PERFORM HEADING.
    PERFORM OUTPUT_BODY.
    FORM HEADING.
    FORMAT INTENSIFIED OFF. " Remove any INTENSIFIED
    ULINE AT (WIDTH). " Upper frame border
    FORMAT COLOR COL_HEADING INTENSIFIED." Title color
    WRITE: / SY-VLINE. " Left border
    WRITE: 'No |Colour |intensified |intensified off|',
    'inverse' NO-GAP.
    WRITE: AT WIDTH SY-VLINE. " Right border
    ULINE AT (WIDTH). " Line below titles
    FORMAT COLOR OFF.
    ENDFORM.
    FORM OUTPUT_BODY.
    DO LENGTH TIMES.
    PERFORM WRITE_LINE USING SY-INDEX.
    ENDDO.
    ENDFORM.
    FORM WRITE_LINE USING COUNT TYPE I.
    DATA: HELP(14) TYPE C,
    COUNT1 TYPE I.
    COUNT1 = SY-INDEX - 1.
    WRITE: / SY-VLINE NO-GAP.
    WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
    WRITE: SY-VLINE NO-GAP.
    CASE COUNT1.
    WHEN '0'.
    HELP = 'COL_BACKGROUND'.
    WHEN '1'.
    HELP = 'COL_HEADING'.
    WHEN '2'.
    HELP = 'COL_NORMAL'.
    WHEN '3'.
    HELP = 'COL_TOTAL'.
    WHEN '4'.
    HELP = 'COL_KEY'.
    WHEN '5'.
    HELP = 'COL_POSITIVE'.
    WHEN '6'.
    HELP = 'COL_NEGATIVE'.
    WHEN '7'.
    HELP = 'COL_GROUP'.
    ENDCASE.
    WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
    WRITE: SY-VLINE NO-GAP.
    WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
    WRITE: SY-VLINE NO-GAP.
    WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
    WRITE: SY-VLINE NO-GAP.
    WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
    WRITE AT WIDTH SY-VLINE NO-GAP.
    ENDFORM.
    Thanks,
    Shankar

  • Change color in a cell in JTable

    Hi, i need to Change color in a cell when this have the focus in a JTable.
    Thanks

    Override the prepareRenderer(...) method. Something like this:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=610474

Maybe you are looking for