Color some Cells in WD ALV

Hello,
im trying to Color some Cells in a Webdynpro ALV.
So far i found out that there are maybe two ways:
one like this with WDUI_TABLE_CELL_DESIGN
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393
but i didnt find out, how to color specified Cells. With this example it is only possible to color the column by the saved color.
the other way is to append a color table to ich column LVC_T_SCOL
and after that
*   We will set this COLOR table field name of the internal table to
*   COLUMNS tab reference for the specific colors   
TRY.       
lo_cols_tab->set_color_column( 'T_COLOR' ).     
CATCH cx_salv_data_error.                         "#EC NO_HANDLER   
ENDTRY.
http://help-abap.blogspot.com/2008/10/salv-table-9-apply-colors.html
but i dont works in Webdynpro ALV. or has someone an idea?
i hope someone can help me.
greets,
Sascha

Hi ,
Check this thread, [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393]
In your case you will have  to create 1 attribute ( type WDY_UIE_LIBRARY_ENUM_TYPE ) for every column. ( for eg: c1, c2, c3 ,c4 , c5 for pt1 pt2 pt3 pt4 pt5 respectively ) and bind it as follows,
*---------- Column settings
  DATA: l_column_settings TYPE REF TO if_salv_wd_column_settings.
  l_column_settings ?= lo_value.
* Get columns
  DATA: lt_columns TYPE salv_wd_t_column_ref ,
        ls_columns TYPE salv_wd_s_column_ref .
  DATA: l_column_header  TYPE REF TO cl_salv_wd_column_header .
  lt_columns = l_column_settings->get_columns( )              .
  LOOP AT lt_columns INTO ls_columns                          .
    CASE ls_columns-id                                        .
      WHEN 'PT1'                                            .
        l_column_header = ls_columns-r_column->get_header( )  .
        l_column_header->set_ddic_binding_field(
           if_salv_wd_c_column_settings=>ddic_bind_none )     .
        ls_columns-r_column->set_cell_design_fieldname( value = 'C1' ). "binding C1 is attribute
      WHEN 'PT2'                                            .
        l_column_header = ls_columns-r_column->get_header( )  .
        l_column_header->set_ddic_binding_field(
           if_salv_wd_c_column_settings=>ddic_bind_none )     .
        l_column_header->set_text( 'Item No' )                .
        ls_columns-r_column->set_cell_design_fieldname( value = 'C2' ). " binding
       ........similarly continue for all the columns.
Now modify your internal table based on your condition and set the required color as follows,
  LOOP AT lt_alv INTO ls_alv.
          if pt1 is lowest. 
            ls_alv-color1 = '02'. " green
          elseif pt2 is lowest.
            ls_alv-color2 = '03'.  "red
          endif.
          MODIFY lt_alv FROM ls_alv INDEX sy-tabix.
        ENDLOOP.
* Bind Data to ALV
        cn_alv->bind_table( lt_alv ).
Hope it helps!
Radhika.

Similar Messages

  • Create deep structure to disable some cells in Dynamic ALV GRID

    Hi,
    I want to disable some cells in a Dynamic ALV Grid before calling "SET_tABLE_Display" Method.
    I check the BCALV_EDIT_02, where some cells are grayed out by assign the  CL_GUI_ALV_GRID-MC_STYLE_DISABLED  to the field name.
    But I want the same using Field symbol.
    I'm creating Dynamic table and dynamic structure based on the Dynamic field catalog.
    Example: <FT_TAB> TYPE STANDARD TABLE,
                    <FS_TAB> TYPE ANY,            
    DATA: INT_TAB  is my dynamic table values.
    For the INT_TAB internal table, I created dynamic Structure and dynamic field symbol table.
    LOOP AT INT_TAB.
    ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    <F_VALUE> = INT_TAB-MATNR.
    APPEND <FS_TAB> TO <FT_TAB>
    "Here is the problem occurs, I want to grayed out the MATNR value based on some condition.
    ENDLOOP.
    I would like to set the 'MATNR' value to be grayed out by passing the CL_GUI_ALV_GRID-MC_STYLE_DISABLED.
    and update into <FT_TAB>(       <FT_TAB> structure will have 2 structures)
    Finally the fieldsymbol should have two structure ( <F_TAB> = DYNAMIC STRUCTURE + LVC_S_STYLE )
    Display alv grid by passing <FT_TAB> to set_table_display method.
    Thanks in advance,
    Kumar.

    Hi,
    I am  not sure whether I really understand your request. Let me try to help.
    > Example: <FT_TAB> TYPE STANDARD TABLE,
    >                 <FS_TAB> TYPE ANY,            
    >
    > DATA: INT_TAB  is my dynamic table values.
    >
    >
    > LOOP AT INT_TAB.
    >  ASSIGN COMPONENT 'MATNR'  OF STRUCTURE <FS_TAB> TO <F_VALUE>
    > <F_VALUE> = INT_TAB-MATNR.
    >  APPEND <FS_TAB> TO <FT_TAB>
    Here <FT_TAB> must already be assigned to some internal table with a given (dynamic) structure. Did this happen before this piece of code?
    What I would do is to create a dynamic table (see documentation to CREATE DATA) with MATNR and the STYLE field (LVC_T_STYL). See the documentation for CREATE DATA - creation of internal tables. When collection the field descriptions for that internal table I would also build the field catalogue for the ALV.
    Then assign <FT_TAB> to that newly created internal table, <FS_TAB> to a newly created structure (same as a table line).
    Move the MATNR to component 1 (or component 'MATNR') of the table and fill the style table according to your needs. Then insert the <FS_TAB> into <FT_TAB>.
    Finally call the ALV SET_TABLE... method with your dynamic table and your field catalogue.
    Regards,
    Gerd Rother

  • Hide some cells while displaying ALV GRID !

    Hi guyz!
        Back with lill query,
        While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
        some cells by default, when the lists is generated.But those cells should
        be  availble to be displayed by the user from ALV layout settings.
        Please advise
    Thanks
    jahan

    Hi, Check for fm documentation.
    Only relevant if layout parameter
    LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
    Complex type for modifying information displayed on the selection dialog box:
    mode:              'R' = Only entries passed in internal table
                              IS_SEL_HIDE-T_ENTRIES are output on
                              the dialog box. Selection information
                              obtained by the list tool by reading the
                              selection screen again (only if the report
                              is called with selection screen) are
                              replaced by the entries passed.
                       'S' = The selection information obtained by the
                              list tool by reading the selection screen
                              of the calling report again, are modified
                              by the entries of table
                              IS_SEL_HIDE-T_ENTRIES.
    t_entries:         Table with selection information
    t_entries-mode:   'A' = Display selection information of the current
                             table row on the information dialog box.
                      'D' = Do not display selection information of the
                             the Select option or of parameter SELNAME
                             on the dialog box.
    t_entries-selname: (required only if t_entries-mode = 'D')
                       name of Select option or parameter
    The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
    t_entries-field:  DDIC field name of the field for which selection
                       information is to be displayed
    t_entries-table:  DDIC table name of t_entries-field.
    t_entries-stext:  Field description on the information dialog box.
                      If t_entries-field and t_entries-table were
                      filled, this text is taken from the DDIC.
    t_entries-valuf:  Selection condition from-value (external format)
    t_entries-valut:  Selection condition to-value (external format)
    t_entries-sign0:  (I)nclusive (E)xclusive
    t_entries-optio:  All values of the option field of the Select
                      option are allowed.
    The remaining fields are used internally and are irrelevant to the caller.
    aRs

  • To color selected cells in dynamically created table in ALV.

    Hi,
           The requirement is to display a table (whose columns are dynamic) using ALV n to color few cells of the table based on some condition.
    For creating the table dynamically i have used the method cl_alv_table_create=>create_dynamic_table.
    Now for coloring the cells i tried to use the field EMPHASIZE .
    But when I try this method the whole column is getting colored.
    So any suggestions on how to color only particular cells.

    Hi,
    Try this one...
    DATA: gs_layout TYPE slis_layout_alv, "Define layout
    gt_color TYPE lvc_t_scol WITH HEADER LINE. "Define Internal Table for Cell Colouring
    Use below Sample Code after building a Field Catalog:
    gs_layout-coltab_fieldname = 'COLINFO'.
    " 'it' is the final internal table which contain positive & negative value of Field 'MENGE'
    LOOP AT it.
    REFRESH gt_color.
    CLEAR gt_color.
    IF it-menge GE 0.
    CLEAR gt_color.
    gt_color-fname = 'MENGE'.
    gt_color-color-col = cl_gui_resources=>list_col_positive.
    gt_color-color-int = 0.
    APPEND gt_color.
    ELSEIF it-menge LE 0.
    CLEAR gt_color.
    gt_color-fname = 'MENGE'.
    gt_color-color-col = cl_gui_resources=>list_col_negative.
    gt_color-color-int = 0.
    APPEND gt_color.
    ENDIF.
    it-colinfo[] = gt_color[].
    MODIFY it.
    ENDLOOP.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = g_repid
    is_layout = gs_layout
    it_fieldcat = ct_fieldcat
    i_save = 'A'
    TABLES
    t_outtab = it
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    Hope this solves your problem.
    Regards,
    Tarun

  • How to remove the orange default color of the first cell in an ALV report

    Hello all,
    I have coded an ALV grid report (in ABAP object) and when I execute it, I saw that the first cell containing data, in the top left corner of the ALV grid is always colored in orange by default. This bothers me because I have colored this cell in green (if I select an other line in my grid, I can clearly see that my top left cell is colored in green).
    Does anyone knows how to "desactivate" this orange default color ?
    Thanks for your answer.
    Best regards
    Cyril S.

    Thanks Uwe and Rainer,
    Unfortunately, I tried what you mentioned both and nothing works.
    As you said, it seems mandatory that a cell must be selected by default in an ALV grid.
    That's a pity because this "ugly orange" hides my beautiful green color.
    I will answer my customer that it is not possible. That's all.
    Thank you for your help. I did appreciate.
    Best regards
    Cyril S.

  • ALV : color one cell

    Hi all,
    i want to color just only one cell in my ALV report, but i don't know how can i do that.
    Here my code :
    REPORT  ztest_alv_color_cell.
    Used to limit user commands on selection-screen
    INCLUDE rsdbc1xx.
    DATA: BEGIN OF i_alv OCCURS 0,
          connid   TYPE sflight-connid,
          currency TYPE sflight-currency,
          FLDATE   TYPE sflight-fldate,
          END OF i_alv.
    DATA: alv_grid       TYPE REF TO cl_gui_alv_grid.
    DATA: fieldcat  TYPE lvc_t_fcat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .
    SELECT-OPTIONS: s_matnr FOR i_alv-connid.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF SCREEN 1010.
    SELECTION-SCREEN END OF SCREEN 1010.
    Events
    AT SELECTION-SCREEN OUTPUT.
      IF sy-dynnr = '1010'.
        current_scr-mode = 'S'.
        APPEND 'SPOS' TO current_scr-excl.
        APPEND 'SCRH' TO current_scr-excl.
        APPEND 'ONLI' TO current_scr-excl.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data.
      CREATE OBJECT alv_grid
             EXPORTING
                   i_parent           =  cl_gui_container=>screen0.
    Populate Field Catalog
      PERFORM get_fieldcatalog.
      CALL METHOD alv_grid->set_table_for_first_display
        CHANGING
          it_outtab       = i_alv[]
          it_fieldcatalog = fieldcat[].
      CALL SELECTION-SCREEN 1010.
    FORM GET_DATA
    FORM get_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
            FROM sflight.
      SORT i_alv ASCENDING BY connid.
    ENDFORM.                    "get_data
         Form  Get_Fieldcatalog - Set Up Columns/Headers
    FORM get_fieldcatalog.
      DATA: ls_fcat TYPE lvc_s_fcat.
      REFRESH: fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Connid'.
      ls_fcat-coltext    = 'Connid'.
      ls_fcat-fieldname  = 'CONNID'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 1.
      APPEND ls_fcat TO fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Currency'.
      ls_fcat-coltext    = 'Currency'.
      ls_fcat-fieldname  = 'CURRENCY'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 2.
      APPEND ls_fcat TO fieldcat.
      CLEAR: ls_fcat.
      ls_fcat-reptext    = 'Flight date'.
      ls_fcat-coltext    = 'Flight date'.
      ls_fcat-fieldname  = 'FLDATE'.
      ls_fcat-ref_table  = 'I_ALV'.
      ls_fcat-datatype   = 'DATS'.
      ls_fcat-outputlen  = '10'.
      ls_fcat-col_pos    = 3.
      APPEND ls_fcat TO fieldcat.
    ENDFORM.                    "get_fieldcatalog
    Imagine that i want to color in red line 1 column 1, please tell how can i do this.
    Thanks very much for help.
    Cheers

    Hi,
    Check this code..
    REPORT  ZTEST1234    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
        MESSAGE I000 WITH V_ROW 'clicked'.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      DATA:BEGIN OF  ITAB OCCURS 0,
           VBELN LIKE LIKP-VBELN,
           POSNR LIKE LIPS-POSNR,
           CELLCOLOR TYPE LVC_T_SCOL, "required for color
           DROP(10),
           END OF ITAB.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      CREATE OBJECT G_CUSTOM_CONTAINER
             EXPORTING CONTAINER_NAME = G_CONTAINER1.
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT ITAB .
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ITAB-POSNR.
          LS_DRAL-INT_VALUE =  ITAB-POSNR.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    Regards
    vijay

  • How to color more than one cell in an ALV line ???

    Hi SDN community,
    I have the following problem:
    I display an internal table with the 'REUSE_ALV_GRID_DISPLAY' function and want to color two cells, not only one cell.
    Coloring one cell is no problem with...
    cell_color1 TYPE lvc_t_scol, " cell color
    DATA  gs_cellcolor    TYPE          lvc_s_scol. " to color a cell
    gs_cellcolor-fname = 'TNAME'.
    gs_cellcolor-color-col = '6'.
    gs_cellcolor-color-int = '1'.
    gs_cellcolor-color-inv = '0'.
    LOOP AT it_result.
      IF it_result-trend EQ 'fast-growing'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
      ENDIF.
    ENDLOOP.
    and
    ls_layout-coltab_fieldname = 'CELL_COLOR1'.
    , the last one is in the layout building form.
    My problem is that in
    ls_layout-coltab_fieldname = 'CELL_COLOR1'.
    , I can only type in ONE fieldname, but I would like to color more than one field/cell, you got my problem?
    Thank you very much,
    Marius

    I'm pretty sure that the color would be controlled by what records are appended to the CELL_COLOR1 table inside IT_RESULT. . So move the code inside the IF statement, and add addition logic.
    LOOP AT it_result.
      IF it_result-trend EQ 'fast-growing'.
       gs_cellcolor-fname = 'TNAME'.
       gs_cellcolor-color-col = '6'.
       gs_cellcolor-color-int = '1'.
       gs_cellcolor-color-inv = '0'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
    else.
       gs_cellcolor-fname = 'OTHER_FIELD'.
       gs_cellcolor-color-col = '5'.
       gs_cellcolor-color-int = '1'.
       gs_cellcolor-color-inv = '0'.
        APPEND gs_cellcolor TO it_result-cell_color1.
        IF sy-subrc EQ 0.
          MODIFY it_result.
        ENDIF.
      ENDIF.
    ENDLOOP.
    Regards,
    Rich Heilman

  • Color a cell in ALV using CL_GUI_ALV_GRID

    Hi,
    How to color a cell using CL_GUI_ALV_GRID?
    Thanks!

    Hi Ezachiael,
    you dont have to trigger event DOUBLE_CLICK, it will be triggered, in case of double click :-).
    You have to implent event handling class and event handler method - It is quite simple.
    Check out this [Reference on SDN|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
    Regards
    REA

  • Color  for a Field in alv output

    Hi All,
    I use a field in the ALV grid output which needs to display color (red or green) depending on certain validations. Please tell me how to display color for this field. The program uses oops.
    Thanks.

    Hi
    1. add one more field to ur final internal table say COLOR(4)
    2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
    wa_layout-style_fieldname = 'COLOR'. "if its list
    3. read table itab index 3.
    itab-color = 'C410'.
    modify itab index 3
    4. see program SHOWCOLO for all color codes
    1. Add a field of data type CHAR(3) to the internal output table.
    2. Enter the color code in the appropriate field of the row to be colored in the internal
    output table:
    Code: 'Cxy'
    C = Color (all codes begin with 'C')
    x = color number ('1' - '9')
    y = highlight ('0' = off, '1' = on)
    3. Assign the internal output table color code field name to the IS_LAYOUT importing
    structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
    interface.
    To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, let’s modify declaration of our list data table “gt_list”.
    you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field “INFO_FNAME” of the layout structure.
    e.g.
    ps_layout-info_fname = <field_name_containing_color_codes>. “e.g. ‘ROWCOLOR’
    You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
    You can color an entire row as described in the next section. However, this method is less time consuming.
    Coloring Individual Cells
    This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by “more” is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
    The structure that should be included must be of type “LVC_T_SCOL”. If you want to color the entire row, this inner table should contain only one row with field “fname” is set to space, some color value at field “col”, “0” or “1” at fields “int” (intensified) and “inv” (inverse).
    If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field “fname”. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
    Reward points if useful
    Regards
    Anji

  • Merge cells in reuse alv

    Hello gurus.
    Please help me with merging cells.
    I need to merge some cells in alv grid. To create grid i use reuse_alv FM. For example it is needed to merge all cells in several rows. What should i do ? I think that there should be some manipulations with fieldcatalog but i don't know the correct ones.
    Thanks.
    regards,
    alex.

    If you would like to merge cells,  meaning that you want to hide repeating values in a certain column, then you can simply sort by that column. 
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: sort     type slis_t_sortinfo_alv.
    data: begin of ivbap occurs 0,
           vbeln type vbap-vbeln,
           kunnr type vbak-kunnr,
           vkorg type vbak-vkorg,
           netwr type vbap-netwr,
          end of ivbap.
    * Selection Screen
    start-of-selection.
      select vbak~vbeln vbak~kunnr vbak~vkorg vbap~netpr
                  into table ivbap
                          from vbak
                             inner join vbap
                                on vbak~vbeln = vbap~vbeln
                                      up to 100 rows.
      perform write_report.
    *  WRITE_REPORT
    form write_report.
      data: tmp_sort type line of slis_t_sortinfo_alv.
      data: fc_tmp type slis_fieldcat_alv .
    * Build feildcat
      clear fc_tmp. refresh fieldcat.
      fc_tmp-reptext_ddic    = 'Sales Org'.
      fc_tmp-fieldname  = 'VKORG'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'Customer'.
      fc_tmp-fieldname  = 'KUNNR'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '10'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'SD DOC'.
      fc_tmp-fieldname  = 'VBELN'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '10'.
      append fc_tmp to fieldcat.
      clear fc_tmp.
      fc_tmp-reptext_ddic    = 'Net'.
      fc_tmp-fieldname  = 'NETWR'.
      fc_tmp-tabname   = 'IVBAP'.
      fc_tmp-outputlen  = '15'.
      fc_tmp-datatype = 'QUAN'.
      append fc_tmp to fieldcat.
    * Build sort table
      clear sort. refresh sort.
      clear tmp_sort.
      tmp_sort-fieldname = 'VKORG'.
      tmp_sort-tabname   = 'IALV'.
      tmp_sort-up        = 'X'.
      append tmp_sort to sort.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_sort     = sort
                it_fieldcat = fieldcat
           tables
                t_outtab    = ivbap.
    endform.
    Regards,
    Rich Heilman

  • How to color particular cell while working REUSE_ALV_HIERSEQ_LIST_DISPLAY

    Hi All,
    I am working with REUSE_ALV_HIERSEQ_LIST_DISPLAY  function module to diaplay hierarchial list. Now my requirement is to color particular cells in the output based on condition. Can any one help me in this regard.
    Thanks and Regards,
    Srinadh.

    hi ,
    try this..
    * FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,                       "internal table for field catalog
           wa_field TYPE slis_fieldcat_alv.                         "work area for field catalog
    * FOR LAYOUT OF ALV GRID
    DATA : wa_layout TYPE slis_layout_alv.                          "work area for layout design
    *&      Form  SET_LAYOUT
    *       SUB-ROUTINE SET_LAYOUT IS USED TO SET THE DISPLAY OF THE
    *       ALV GRID LINES IN ALTERNATIVE COLOURS
    FORM set_layout .
      wa_layout-zebra = 'X'.
    ENDFORM.                    " SET_LAYOUT
    *&      Form  ALV_DISPLAY
    *       SUB-ROUTINE ALV_DISPLAY IS USED TO SET THE PARAMETERS
    *       FOR THE FUNCTION MODULE REUSE_ALV_GRID_DISPLAY
    *       AND PASS THE INTERNAL TABLE EXISTING THE RECORDS TO BE
    *       DISPLAYED IN THE GRID FORMAT
    FORM alv_display .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = 'SY-REPID '
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_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                      =
    *     I_GRID_SETTINGS                   =
         is_layout                         = wa_layout
         it_fieldcat                       = it_field
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
    *     IT_SORT                           =
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
    *     I_SAVE                            = ' '
    *     IS_VARIANT                        =
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT                          =
    *     IS_REPREP_ID                      =
    *     I_SCREEN_START_COLUMN             = 0
    *     I_SCREEN_START_LINE               = 0
    *     I_SCREEN_END_COLUMN               = 0
    *     I_SCREEN_END_LINE                 = 0
    *     I_HTML_HEIGHT_TOP                 = 0
    *     I_HTML_HEIGHT_END                 = 0
    *     IT_ALV_GRAPHICS                   =
    *     IT_HYPERLINK                      =
    *     IT_ADD_FIELDCAT                   =
    *     IT_EXCEPT_QINFO                   =
    *     IR_SALV_FULLSCREEN_ADAPTER        =
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER           =
    *     ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_final
    *   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.                    "alv_display
    regards
    Ritesh J

  • Making some cells bolded in web dynpro table

    Hi,
    I searched but i did not find suitable solution about bolding and coloring text in some cells in web dynpro table.
    Is it possible?
    If possible is there code sample?
    Thanks.

    hi
    check this links 
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417400)ID1938237850DB02101680362526771086End?blog=/pub/wlg/3548
    How to make last row in the table in Bold font

  • Color a cell when i select THAT cell

    Hi!
    I searced for something about my question, but i didn't find anything about it :/
    I have to color one cell of a JTable when i select it and make some operation.
    I tried with this:
    java.awt.Component cell = jTable1.getComponentAt(jTable1.getSelectedColumn(),jTable1.getSelectedRow());
                     cell.setForeground(java.awt.Color.red);But it color all my table and not THE cell that i've selected.
    If i've understood, the overriding of the metods prepareRenderer (or similar, i don't remember its exact name) sets the color of cells under particulare condition, but i think i don't need it: i have to color a cell only when i select it.
    Thank you!

    but i think i don't need it: i have to color a cell only when i select it. Why don't you think you need it. You have a special requirement that you only want to give the cell a specific color when it is selected. So the prepareRenderer() method should do what you want.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.

  • Color table cells depending on value of entry in row (UI5 & JSON)

    Hello all,
    I've stuck here a bit. There have been some discussions about how to color the cells of a table that has been bound to a JSON data model. I found some answers how to color individual cells (http://http://scn.sap.com/thread/3383698), but I have a hard time to fulfill the following requirement (rephrased for simplicity):
    Given value "a" in the first cell of a table row, color the row cells 1 - 4 in blue, and 5-7 in red.
    Given value "b" in the first cell of a table row, color the row cells 1 - 4 in yellow and 5-7 in green.
    This wouldn't be a problem with normal HTML as I could easily assign style classes to every cell, however I can't find the solution for the UI5 table.
    Any ideas?
    Thanks,
    Christian

    Hi Nishant,
    not sure if I undestand you correctly.
    When I scroll the table, the data scrolls with the table correctly, but in the "Last Name" column the formatting gets messed up.
    To solve this, you need to remove the previously added classes:
      // Approach 2
        template = new sap.ui.commons.TextView().bindProperty("text", {
                parts: [
                    {path: "***" },
                    {path: "lname" }
                formatter: function(***, lname){
                   // Remove previously added classes
                  this.removeStyleClass("cyan").removeStyleClass("yellow");
                  if(*** == "m" ){
                    <!-- approach 2 step B : Add Css style class to element -->
                    this.addStyleClass("yellow");
                  }  else  if(*** == "f" )
                       this.addStyleClass("cyan");
                  return lname ;
        oTable.addColumn(new sap.ui.table.Column({ label: "Last Name",
                template: template,
    Same for the first approach using where you have to remove the custom data instead if the class.
    This should solve the problem. (By the way this is already mentioned in this thread in my post from Mar 10, 2014 11:40 AM)
    Greeets,
    ben

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

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

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

Maybe you are looking for

  • Issue with Resubmission in WS12300111

    Hi Experts,                   In my leave workflow when a request is rejected by the employee I am getting a workitem in my portal "Process Leave Request by Employee", when I resubmit the request system is triggering a new request instead of provcess

  • How can I change Apple ID for App Store?

    I changed my Apple ID, Itunes on my Itouch recognizes it, but the app store does not. How can I change AppleID for App Store? When I try to update my apps it asks for the password for my old Apple ID which does not exist anymore.

  • Updated itunes to use ipad mini and itunes wont start up now?

    i have a ipad3 + iphone4 + ipod touch and just brought ipad mini pluged it into itunes then itunes says have to update to use with ipad mini so i updated it like normal restarted pc and now doesnt work try reinstalling and repairing files still didnt

  • Check Connection of Communication Arrangement for SAP ERP Financials Using IDoc Failed

    Dear experts, We are checking outbound connection from C4TE to ERP in Communication Arrangement for SAP ERP Financials Using IDoc Failed. We get the attached error message: Checking connection failed Error accessing service; Service Ping ERROR: Forbi

  • Mail Services keeps shutting down

    I have been plaque with this problem for about two months. I have 5 static ips and I use one of the ips to host a webserver and very small mail server. I am on DSL. My problem is my mail server always shuts down after a couple hours. The error is 127