JTable: aligning particular cells

Assuming that the programmer does not know beforehand the number of rows a JTable will have, how can he/she go about right-aligning all the cells of a particular column (say the 3rd and 4th)?
Would I need to use TableCellRenderer? And if so, how do I go about doing this?
Cheers!

I think you will be good with the other post, but anyway...
What I meant was that if the column to be right-justified was of the same type as a column that should not be right-justified then you cannot use the table.setDefaultRenderer method. Then you must either add the rederer to a specific column or in the rederer use the correct component depending on the column passed.
If only the columns to be right-justified are of that type then you are good and can do the following.
table.setDefaultRenderer (Integer.class, myRenderer);
table.setDefaultRenderer (Double.class, myRenderer);

Similar Messages

  • Setting Focus to a particular cell in JTable

    Hi, can i know how to set the focus to a particular cell in JTable.
    Say I have a table with 2 rows and 10 columns. The focus now is at position (1, 9) which is the last cell in the table. But I want to set the focus to (1, 3). How can i achieve this ? Pls help. Thanks

    OK. It's partially working. The right methods to use are setRowSelectionInterval and setColumnSelectionInterval. Jeanette was right. Mine didn't work because of a thread issue. I put the those two methods in a block such as:
    SwingUtilities.invokeLater(new Runnable(){
    public void run()
    table.setRowSelectionInterval(tblLineItem.getRowCount()-1,
    table.getRowCount()-1);
    table.setColumnSelectionInterval(0,0);
    Then it worked.
    But after I finished editing the first cell of the newly created row and press ENTER, the selection went back to the cell that's next to the originally editing cell on the first(old) row, instead of staying at the current row and going to the second cell.
    Can anybody shed a light on what I'm missing?

  • How to insert checkbox at a particular  cell  in jtable

    hello,
    I am a user of jdeveloper using jclient/swing .
    question:
    i am using jtable. i want that whenever i click on a specified cell then text at that particular cell get clear and a checkbox inserted in that cell . whenever i click on that checkbox i.e check the checkbox,
    again a text is inserted in that cell.
    thank you

    Did you ever get this to work? If I bind a JCheckbox to my attribute and add the checkbox to my JClient panel, the attribute value is properly bound to the checkbox with everything working correctly. Adding the checkbox as the TableCellEditor for the column doesn't work.
    Also, the link to using a Combobox as a table cell editor works, but the link doesn't tell where to donwload the sample code from. Doesn't anyone know the link?

  • How to disable a particular cell in JTable ?

    I having a problem on how to set disable a particular cell in JTable. At the first place to load the JTable, I want to set some of the cell to disabled, it only will run at the first time, is there anyway to do it ?

    This is the function that disable/enable cells in JTables.
    Are you looking for this?
    public boolean isCellEditable(int row, int col)
      if(((new Integer((String)(getValueAt(row,0)).toString()).intValue()>9))&&(col==1))
        return true;
      if(row!=4&&col!=5)
        return true;
      return false;
         this metod belong to the TableModel function
    and what I gave you is only an example of what you can do with it.
    if it return false it disable and if true it enable the cell...but I think this you allready know!
    Regards Amnon

  • Change particular cell color when finised editing and when lost focus

    Hi, i want to create a table which its particular cell can change its color automatically to red if the value in cell in column in two is smaller than column cell value in column 1 when user finish typed a value or if the cell has lost focus. I've wrote a code for the renderer but how should I use action, KeyListener or MouseLister or both
    * File ColouredCellRenderer.java
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.DefaultTableCellRenderer;
    public class ColouredCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer{
        private Object col1Value, col2Value;
        public ColouredCellRenderer(Object args1, Object args2){
            this.col1Value = args1;
            this.col2Value = args2;
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
              return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
         protected void setValue(Object v){
              super.setValue(v);
            if((col1Value != null) & (col2Value != null)){
                int x = Integer.parseInt(col1Value.toString());
                int y = Integer.parseInt(col2Value.toString());
                if(x > y){
                    this.setBackground(Color.RED);
                else{
                    this.setBackground(Color.GREEN);
    }

    All you should need is the cell renderer to achieve that effect. Whenever the table needs to render a cell it will call the method
    getTableCellRendererComponent(...);This method in turn returns a component showing what the cell should look like. The DefaultTableCellRenderer extends JLabel, so you are meant to customize the label (based on parameters that were passed) and return this* at the end of the method.
    public Component getTableCellRendererComponent(...) {
             return this;
    }This one label is used to render all the cells of all the columns that the cell renderer is assigned to. Since you want some cells too be red, you should call setBackground(Color.red)+ when the conditions are appropriate or null otherwise.

  • Is there any way to tell which formulas a particular cell is in, reverse look-up style? That is, is there a way to search somehow for which formulas in a sheet contain a particular cell in them without opening all of them up? If not, it would be nice

    Is there any way to tell which formulas a particular cell is in, reverse look-up style? That is, is there a way to search somehow for which formulas in a sheet contain a particular cell in them without opening all of them up? If not, it would be nice.
    I'm fixing a Numbers document that I use in business daily that's become overly complicated, but while I want to clear/delete a number of cells in it to clean it up, I'm not sure if those cells are being used as source for other formulas on the page. I don't have to open all my formulas one by one to see if that cell is in there, do I?! That'd be a huge amount of work if I wanted to eliminate say 10 cells to search each formula on the page to see if it is in there or watch all the cells when I delete that cell to see if the numbers change! There's got to be an easier way! Right click doesn't seem to be any help.
    I don't want to damage my daily tool to make it cleaner and reorganize it. Is there really no way to do a reverse look-up of which formulas a particular cell is in?! Any time I click on a formula it highlights all the CELLS in that formula. Why can't I (or can I?) do the reverse and see all the FORMULAS that contain a particular cell?
    As a Numbers document ages or gets used frequently, you can sometimes forget which cells are tied to which formulas. You just look for the results of your formulas. Would be a nice thing to be able to do. Thoughts? Work-arounds? Answers?

    Answer would be no unless application provided such feature. Numbers does not as far as I know.
    Note that even if you have complete list of formulae used in a table, identifying formulae referencing any given cell is not simple.
    E.g., cell T20 is referenced not only in
    =T20+1
    but also in
    =SUM(T)
    =SUM(20:20)
    =SUM(S19:U22)
    =OFFSET(S1,19,1,1,1)
    =INDIRECT("T"&(10*2))
    In order to identify such formula, we have to actually evaluate it to see if it references the given cell. Especially such formula as OFFSET() and INDIRECT() may not be found by static parser because their parameters can be dynamic.
    Sorry to be the bearer of bad tidings.
    H

  • HOW TO GET VALUE OF A PARTICULAR CELL IN ALV GRID

    I HAVE 2 ALV GRID. IWANT WHEN I DOUBLE CLICK ON ANY PARTICULAR CELL OF FIRST GRID I WILL GET THE VALUE DISPLAYED ON THAT PARTICULAR CELL.
    THANKS IN ADVANCE

    Hi,
    If you are using a class alv, you only need to create a local class to control event and, before setting the screen to present the alv, you need to assign the class as a handler, like this:
        CREATE OBJECT event_handler.
        SET HANDLER event_handler->double_click FOR alv_grid.
    This event handler was defined before like below and a object was created for it:
    CLASS cl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS double_click FOR EVENT double_click OF cl_gui_alv_grid
          IMPORTING e_row e_column.
    ENDCLASS.                    "cl_event_handler DEFINITION
    Then you need to implement this class, creating the method double click and do a READ TABLE to the itab you presented in the alv to recover the data, like this:
        READ TABLE itab INTO wk_itab
          INDEX e_row-index.
    The e_row structure was sent to the method by the handler, setting it with the line index that you double clicked in the alv. After that, you can manipulate the data that you selected in your internal table to generate the data to the other ALV.
    Best Regards,
    -h

  • Set back ground color to a particular cell in table view

    hi,
        iam working on a jspDynpage and have a htmlb table view for which i need a way to set back ground color to a particular cell in table view, the color has to be set based on a value..is there a way to do it without using an iterator...well iam using a  cellRenderer for the table but cant find a way to set the colors...if anyone does have a way please do reply...regards

    You can mention the color in <b>textview</b> as well as <b>Label as follows:</b>
          <htmlb:textView     text          = "<span style='background-color: #00FF00'>My Textview</span>"
                              design        = "EMPHASIZED" />
          <htmlb:label for =  "MyLabel"
                       text = "<span style='background-color: #00FF00'>Label </span>"
                       encode = "false"/>
    Reward each helpful answer
    Raja T
    Message was edited by:
            Raja Thangamani

  • How to disable a particular CELL in matrix?????

    Hi All,
               I have a doubt regarding the matrix.In my matrix the first column is a combobox it has a,b,c items....so if i select 'a' the remaining 'b' & 'c' columns should get disabled....previously iam able to disable the 'b' & 'c' columns but it's disabling the total 'b & 'c' columns in my matrix.....i just want to disable the particular cell based on the combobox selection....can we disable a particular cell in matrix.....
    regards,
    shangai.

    Shangai,
    here were many threads about this in last month. Try to search in history.
    BTW, the particular cell cannot be disabled (only whole column), but you could make system, that the cell is enabled but you cannot click on it (when user clicks on the cell, set bubbleeevnt to fasle).

  • 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 print a particular cell data from .xls file

    InputStream inputStream =new FileInputStream("D:\\test.xls");
    POIFSFileSystem fileSystem=new POIFSFileSystem (inputStream);
    HSSFWorkbook workBook = new HSSFWorkbook (fileSystem);
    HSSFSheet sheet = workBook.getSheetAt (0);
    Iterator<HSSFRow> rows = sheet.rowIterator ();
    HSSFRow row = rows.next ();
    Iterator<HSSFCell> cells = row.cellIterator ();
    HSSFCell cell = cells.next ();
    can any get me answer to print the particular cell from the excel sheet.
    Regards
    Praveen

    Thank you for your response
    when i written the in following way
    HSSFWorkbook workbook = new HSSFWorkbook(new
    FileInputStream("D:\\sam.xls"));
    HSSFSheet sheet = workbook.getSheetAt(1);
    HSSFRow row = sheet.getRow(0);
    HSSFCell cell = row.getCell((short)3);
    int as= sheet.getFirstRowNum();
    int bs=sheet.getLastRowNum();
    System.out.println("Begin of row"+as);
    System.out.println("End of row"+bs);
    Is Displayed as
    Begin of row 0
    End of row 0
    can any one plz let me know the procedures to print first and last row number of a .xls sheet
    ans also the column number please.

  • 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 print the row  ,column,and particular cell in separate color

    how to print the row  ,column,and particular cell in separate color IN ALV GRID

    HI,
    Here you go good program links
    <a href="http://www.sapfans.com/forums/viewtopic.php?t=52107">How to Set Color to a Cell in AVL</a>
    <a href="http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm">ALV Grid Coloring</a>
    Thanks
    Mahesh

  • How to display an image in particular cell editor

    Hi All,
    I want to display an image as the background for the table cell.
    I searched in sdn and found the solution only for link to action.
    I have created a dynamic table and if i click on apply button one more row is getting added according to my requirement.
    I want to differentiate this row from rest.  So I need to display image for the last row in the table which is added newly. 
    Can anyone suggest the procedure for adding an image in a particular cell editor along with the table data?
    Hope I am clear with my requirement.
    Pls suggest.
    Regards,
    subashini

    Hi,
    IF iam not wrong then for some rows u need to show text data and for some rows u need to show image data.
    follow the following steps.
    1. In ur table add cell editor of type Image.
    2.Create a value node with one more than required attributes.
    3.Suppose if need to show only one column then i will create  
       value node with two attributes.One attribute will be for text
      data and one will for Image.
    4.now access ur table cell editor dynamically.For image type
      cell editor we need to play only with two properties source
    and alt.Bind this alt property of editor wid that attribute which u
    need use for text data and source wid that attribute which u
    need to use for image.
    5.  Now suppose I need to show text data then
    I will create one element of that value node.In case of Image
    type cell editor source property  is given prefrence over alt
    property.
    set attribute which is bound to alt to the actual text data
    i.e setText("Actual text data");
    and set attribute which is bound to source to some dummy
    image name
    i.e setImage("dummy.gif");
    add this to node.
    during execution as source property of editor is bound to
    Image attribute of node  which in turn is set to dummy value it
    wont find actual source and will set Image cell editor with
    watever is bound to alt property which in turn set with actual
    text value..
    6.  Now suppose I need to show Image data then
    I will create one element of that value node.In case of Image
    type cell editor source property  is given prefrence over alt
    property.
    set attribute which is bound to alt to blank value 
    i.e setText("");
    and set attribute which is bound to source to some Actual 
    image name
    i.e setImage("Image.gif");
    add this to node.
    during execution as source property of editor is bound to
    Image attribute of node which in turn is set to Actual image file
    it will  set Image cell editor with that image name  and wont look for alt property.
    Copy all ur images in src->mimes->components->ur package
    Regards
    Surender Dahiya

  • To change the colour of the particular cell of ALV report in Grid display.

    Hai Friends,
                      I have created an Alv report in grid display .In that i want to change the colour of the particular cell.Plz provide the answer with a solved example.
             Thank u.

    This works for a Custom Control and OO ALV in a Dialog Module
    TABLES: kna1.
    * Data (for the ALV Grid)
    TYPES:
      BEGIN OF t_alv_data,
        cust_id    TYPE kunnr,        "Customer Number
        cust_name  TYPE name1_gp,     "Customer Name
        cust_color TYPE i,
    *   cell coloring field
        color     TYPE lvc_t_scol,   "Cell coloring
      END OF t_alv_data.
    DATA:
      v_alv_data TYPE t_alv_data,
      i_alv_data TYPE STANDARD TABLE OF t_alv_data.
    * ALV grid containers and objects
    DATA:
      o_alv_grid TYPE REF TO cl_gui_alv_grid,
      o_alv_cont TYPE REF TO cl_gui_custom_container.
    * ALV field catalog
    DATA:
      i_alv_fc TYPE lvc_t_fcat,
      v_alv_fc LIKE lvc_s_fcat.
    * ALV Layout (colors)
    DATA:
      v_alv_layout TYPE lvc_s_layo,
      i_alv_color TYPE lvc_t_scol,
      v_alv_color TYPE lvc_s_scol,
      v_alv_color_cell TYPE lvc_s_colo.
    * ALV variant
    DATA:
      v_alv_variant  TYPE disvariant.
    PARAMETERS:
      p_alvvar TYPE disvariant-variant DEFAULT 'DEFAULT'.
    DATA: ok_code LIKE sy-ucomm.
    * Class for event handling
    *       CLASS lcl_event_receiver DEFINITION
    * [+] Event listener for the ALV grid
    * [+] Handles hotspots and data changes
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
    *     Hotspot clicking
          hotspot_click
               FOR EVENT hotspot_click OF cl_gui_alv_grid
                 IMPORTING e_row_id
                           e_column_id
                           es_row_no,
    *     Data changed (such as checkbox clicking)
          handle_data_changed
            FOR EVENT data_changed OF cl_gui_alv_grid
                IMPORTING er_data_changed.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    *       CLASS lcl_event_receiver IMPLEMENTATION
    * [+] Implementation of the ALV Grid event handler class
    CLASS lcl_event_receiver IMPLEMENTATION.
    *       METHOD hotspot_click                                          *
    * [+] Calls evvent_hotspot_click when a hotspot is clicked in the ALV
      METHOD hotspot_click.
        PERFORM event_hotspot_click
                      USING e_row_id
                            e_column_id.
      ENDMETHOD.                    "hotspot_click
    *       METHOD handle_data_changed                                    *
    * [+] Updates the source data when the data in the ALV display has
    * been changed, such as by clicking a checkbox.
      METHOD handle_data_changed.
        DATA: lv_changed TYPE lvc_s_modi.
        LOOP AT er_data_changed->mt_good_cells INTO lv_changed
          WHERE fieldname = 'CUST_NAME'.
          READ TABLE i_alv_data INTO v_alv_data INDEX lv_changed-row_id.
          IF sy-subrc = 0.
            MOVE lv_changed-value TO v_alv_data-cust_name.
            MODIFY i_alv_data FROM v_alv_data INDEX lv_changed-row_id.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    * Reference to the event listener class
    DATA: event_receiver TYPE REF TO lcl_event_receiver.
    *       FORM build_event_listener
    * [+] Set the event handler on the ALV Grid
    FORM build_event_listener.
    * Assigning the event listener to the ALV
      CREATE OBJECT event_receiver.
      SET HANDLER event_receiver->handle_data_changed FOR o_alv_grid.
      SET HANDLER event_receiver->hotspot_click       FOR o_alv_grid.
    ENDFORM.                    "build_event_listener
    *       AT SELECTION-SCREEN
    *         ON VALUE-REQUEST FOR p_alvvar
    * [+] Calls choose_alv_variant to ask the user to select an alv grid
    *     layout variant
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_alvvar.
      PERFORM choose_alv_variant
        CHANGING
          p_alvvar
          v_alv_variant.
    *       START_OF_SELECTION
    START-OF-SELECTION.
      PERFORM get_data.
      SET PF-STATUS 'ALVSCREEN' IMMEDIATELY.
      CALL SCREEN 2000.
    *       FORM get_data
    * [+] Gets the data for the ALV grid
    FORM get_data.
      SELECT kunnr name1
        INTO (v_alv_data-cust_id,
              v_alv_data-cust_name)
        FROM kna1.
        APPEND v_alv_data TO i_alv_data.
      ENDSELECT.
    ENDFORM.                    "get_data
    *       MODULE build_alv_grid
    *   THIS SHOULD BE IN THE "PROCESS BEFORE OUTPUT" OF THE ALV SCREEN
    * [+] Builds the ALV Grid objects
    * [+] Calls to build the field catalog table
    * [+] Loads the field catalog table into the ALV Grid
    * [+] Loads the table data into the ALV Grid
    MODULE build_alv_grid OUTPUT.
      SET TITLEBAR  '2000'.
    * Also enables layout saving
      PERFORM set_alv_variant
        USING
          p_alvvar
        CHANGING
          v_alv_variant.
    * Building the grid and container on the screen
    * NOTE: the container name MUST be upper-case
    * Also, we don't want the objects to be created if in batch mode!
      IF sy-batch IS INITIAL.
        CREATE OBJECT o_alv_cont
          EXPORTING
            container_name = 'O_ALV_TABLE'.
      ENDIF.
      CREATE OBJECT o_alv_grid
        EXPORTING
          i_parent = o_alv_cont.
    * builds the event listener
      PERFORM build_event_listener.
    * Color the cells
      PERFORM color_cells.
    * Build the field catalog
      PERFORM build_alv_fc.
    * Loads the data into the grid
      CALL METHOD o_alv_grid->set_table_for_first_display
        EXPORTING
          i_save          = 'A'
          i_default       = 'X'
          is_variant      = v_alv_variant
          is_layout       = v_alv_layout
        CHANGING
          it_outtab       = i_alv_data
          it_fieldcatalog = i_alv_fc.
    ENDMODULE.                    "build_alv_grid OUTPUT
    *       FORM build_alv_fc
    * [+] Constructs the ALV Grid field catalog table
    FORM build_alv_fc.
      CLEAR i_alv_fc.
      REFRESH i_alv_fc.
    * NOTE: the field name MUST be upper-case
    *                   field       heading         hide  hot
    *                   name                        zero  spot  just
      PERFORM:
        alv_field USING 'CUST_ID'    'Cust ID'        ' '  'X'  'R',
        alv_field USING 'CUST_NAME'  'Customer Name'  ' '  ' '  'L',
        alv_field USING 'CUST_COLOR' 'Color'          ' '  ' '  'R'.
    ENDFORM.                    "build_alv_fc
    *       FORM alv_field
    * [+] Describes and constructs a single field for the ALV Grid field
    *     catalog. The field length and type are both obtained from the
    *     actual field passed in to this method.
    * [+] Adds the constructed field to the ALV Grid field catalog table
    FORM alv_field
      USING
        p_field_name TYPE c
        p_heading    TYPE c
        p_hide_zeros TYPE c
        p_hotspot    TYPE c
        p_justify    TYPE c.
      CLEAR v_alv_fc.
      DATA:
        lv_type(1) TYPE c,
        lv_length TYPE i,
        lv_heading_length TYPE i.
    * get the type and length of this field
      FIELD-SYMBOLS <field>.
      ASSIGN p_field_name TO <field>.
      DESCRIBE FIELD <field> TYPE lv_type OUTPUT-LENGTH lv_length.
    * re-adjust the length to the length of the header, if too short
      lv_heading_length = strlen( p_heading ).
      IF lv_length < lv_heading_length.
        lv_length = lv_heading_length.
      ENDIF.
    * NOTE: the field name MUST be upper-case
      v_alv_fc-fieldname = p_field_name.
      TRANSLATE v_alv_fc-fieldname TO UPPER CASE.
      v_alv_fc-inttype   = lv_type.
      v_alv_fc-outputlen = lv_length.
      v_alv_fc-coltext   = p_heading.
      v_alv_fc-seltext   = p_heading.
      v_alv_fc-hotspot   = p_hotspot.
    * Determining which fields should show zeros
      IF p_hide_zeros = 'X'.
        v_alv_fc-no_zero = 'X'.
        v_alv_fc-lzero   = ' '.
      ELSE.
        v_alv_fc-no_zero = ' '.
        v_alv_fc-lzero   = 'X'.
      ENDIF.
      v_alv_fc-just = p_justify.
    * Add the field to the field catalog
      APPEND v_alv_fc TO i_alv_fc.
    ENDFORM.                    "alv_field
    *       FORM choose_alv_variant
    * [+] Shows a popup that allows the user to choose the layout variant
    *     for the alv grid of the current program
    * [+] Usually called by an AT SELECTION-SCREEN method.
    FORM choose_alv_variant
      CHANGING
        p_variant_name TYPE disvariant-variant
        p_variant      TYPE disvariant.
      CLEAR p_variant.
      DATA:
        p_exit_check(1) TYPE c.
      MOVE sy-repid TO p_variant-report.
      CALL FUNCTION 'LVC_VARIANT_F4'
           EXPORTING
                is_variant = p_variant
                i_save     = 'A'
           IMPORTING
                e_exit     = p_exit_check
                es_variant = p_variant
           EXCEPTIONS
                not_found  = 1
                OTHERS     = 99.
      IF sy-subrc = 0.
        IF p_exit_check <> 'X'.
          p_variant_name = p_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    "choose_alv_variant
    *       FORM set_alv_variant
    * [+] Sets the alv grid layout variant. Used for setting the variant
    *     when its name is entered in a parameter rather than by using the
    *     popup, or when loading the variant from a variable of type C
    FORM set_alv_variant
      USING
        p_variant_name TYPE disvariant-variant
      CHANGING
        p_variant      TYPE disvariant.
      MOVE sy-repid TO p_variant-report.
      p_variant-variant = p_variant_name.
    ENDFORM.                    "set_alv_variant
    *       FORM color_cells
    * [+] Loop through the data and apply coloring
    FORM color_cells.
      DATA:
        my_color  TYPE i.
    * tell the ALV grid what field in v_alv_data contains color information
      v_alv_layout-ctab_fname = 'COLOR'.
      my_color = 0.
    * loop through each row of the table
      LOOP AT i_alv_data INTO v_alv_data.
    *   clear the variables
        CLEAR:
          v_alv_color,
          v_alv_color_cell,
          i_alv_color.
        REFRESH:
          i_alv_color.
        v_alv_data-cust_color = my_color.
        PERFORM color_cell USING 'CUST_COLOR' my_color. "negative
    *   apply the colors
    *    IF v_alv_data-cust_name = 'Testing Credit'.
    *      PERFORM color_cell USING 'CUST_NAME' 6. "negative
    *    ELSEIF v_alv_data-cust_name = 'Goober Goober Also'.
    *      PERFORM color_cell USING 'CUST_NAME' 5. "positive
    *    ENDIF.
    *   set the color data for this table row
        v_alv_data-color = i_alv_color.
        MODIFY i_alv_data FROM v_alv_data.
        my_color = my_color + 1.
        IF my_color GT 7.
          CLEAR my_color.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "color_cells
    *       FORM color_cell
    * [+] Colors a cell in the ALV grid
    FORM color_cell
      USING
        p_cellname TYPE c
        p_color    TYPE i.
      CLEAR:
        v_alv_color_cell,
        v_alv_color.
    * set the color for the cell
    *  IF p_color = 0.
    *    v_alv_color_cell-col = 0. "cl_gui_resources=>list_col_background.
    *  ELSEIF p_color = 1.
    *    v_alv_color_cell-col = 1. "cl_gui_resources=>list_col_heading.
    *  ELSEIF p_color = 2.
    *    v_alv_color_cell-col = 2. "cl_gui_resources=>list_col_normal.
    *  ELSEIF p_color = 3.
    *    v_alv_color_cell-col = 3. "cl_gui_resources=>list_col_total.
    *  ELSEIF p_color = 4.
    *    v_alv_color_cell-col = 4. "cl_gui_resources=>list_col_key.
    *  ELSEIF p_color = 5.
    *    v_alv_color_cell-col = 5. "cl_gui_resources=>list_col_positive.
    *  ELSEIF p_color = 6.
    *    v_alv_color_cell-col = 6. "cl_gui_resources=>list_col_negative.
    *  ELSEIF p_color = 7.
    *    v_alv_color_cell-col = 7. "cl_gui_resources=>list_col_group.
    *  ENDIF.
      v_alv_color_cell-col = p_color.
      v_alv_color-nokeycol = 'X'.
      v_alv_color-fname = p_cellname.
    *  v_alv_color-color = p_color.
      v_alv_color-color = v_alv_color_cell.
      APPEND v_alv_color TO i_alv_color.
    ENDFORM.                    "color_cell
    *       FORM event_hotspot_click
    * [+] What to do when clicking on a hotspot in the ALV Grid
    FORM event_hotspot_click
      USING
        p_row    TYPE lvc_s_row
        p_column TYPE lvc_s_col.
      DATA:
        lv_docnum TYPE kunnr.
      READ TABLE i_alv_data INTO v_alv_data INDEX p_row-index.
      IF p_column = 'CUST_ID'.
    *   call a transaction when the cust_id is clicked
        SET PARAMETER ID 'AUN' FIELD v_alv_data-cust_id.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
    ENDFORM.                    "event_hotspot_click
    *&      Module  USER_COMMAND_2000  INPUT
    *       text
    MODULE user_command_2000 INPUT.
      CASE ok_code.
        WHEN 'BACK'
          OR 'STOP'
          OR 'CANCEL'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_2000  INPUT

Maybe you are looking for