Tabbing editable fields in JTable

{noformat}{noformat}HI All,
I'd like to be able to tab between cells and the cell to immediately go into edit mode. Additionally I'd like it to
skip uneditable cells, so tabbing on a far right cell doesn't move to the label on the
next row, but to the next editable cell in the next row. This code was posted in a different newsgroup and it works mostly.
It does not tab to the next editable cell in the next row. The focus is back to the first editable column in the same row.
How do I make it go the next row.? The getSelectedRow() method always returns the first selected row.
Any suggestions or help is appreciated.
bq. {noformat} import javax.swing.*; \\ import javax.swing.border.Border; \\ import javax.swing.border.EmptyBorder; \\ import javax.swing.table.TableCellRenderer; \\ import javax.swing.table.DefaultTableCellRenderer; \\ import javax.swing.table.DefaultTableModel; \\ import java.awt.*; \\ public class TableTest extends JFrame { \\ public TableTest() \\ { \\ getContentPane().add(new MyTable()); \\ } \\ public static void main(String[] args) \\ { \\ TableTest frame = new TableTest(); \\ frame.setDefaultCloseOperation(EXIT_ON_CLOSE); \\ frame.pack(); \\ frame.setVisible(true); \\ } \\ public class MyTable extends JTable \\ { \\ public MyTable() \\ { \\ super(new MyTableModel()); \\ putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); \\ setDefaultRenderer(String.class, new Renderer()); \\ DefaultCellEditor dce = new DefaultCellEditor(new JTextField()); \\ dce.setClickCountToStart(1); \\ setDefaultEditor(String.class, dce); \\ setOpaque(false); \\ setShowGrid(false);{noformat}{noformat}     configure(); \\ } \\ {noformat}{noformat}     private void configure() \\ { \\ setSelectionMode(ListSelectionModel.SINGLE_SELECTION); \\ setCellSelectionEnabled(true); \\ // Add SelectionListeners to track selection changes \\ // across columns. \\ getColumnModel().getSelectionModel().addListSelectionListener( \\ new ExploreSelectionListener()); \\ } \\ private class ExploreSelectionListener implements ListSelectionListener \\ { \\ public void valueChanged(ListSelectionEvent e) \\ { \\ if(!e.getValueIsAdjusting()) \\ { \\ int row = getSelectedRow(); \\ int col = getSelectedColumn(); \\ // Make sure we start with legal values. \\ while(col < 0) col++; \\ while(row < 0) row++; \\ // Find the next editable cell. \\ while(!isCellEditable(row, col)) \\ { \\ col++; \\ if(col > getColumnCount()-1) \\ { \\ col = 1; \\ row = (row == getRowCount()-1) ? 1 : row+1; \\ } \\ } \\ // Select the cell in the table. \\ final int r = row, c = col; \\ EventQueue.invokeLater(new Runnable() \\ { \\ public void run() \\ { \\ changeSelection(r, c, false, false); \\ } \\ }); \\ // Edit. \\ if(isCellEditable(row, col)) \\ { \\ editCellAt(row, col); \\ ((JTextField)editorComp).selectAll(); \\ editorComp.requestFocusInWindow(); \\ } \\ } \\ } \\ } \\ private class Renderer implements TableCellRenderer \\ { \\ DefaultTableCellRenderer renderer; \\ JTextField textField; \\ protected Border border = new EmptyBorder(1, 1, 1, 1); \\ public Renderer() \\ { \\ renderer = new DefaultTableCellRenderer(); \\ textField = new JTextField(); \\ textField.setHorizontalAlignment(SwingConstants.RIGHT); \\ } \\ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) \\ { \\ if (!isCellEditable(row, column)) \\ { \\ renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); \\ renderer.setHorizontalAlignment(column == 0 ? SwingConstants.LEFT : SwingConstants.RIGHT); \\ renderer.setBackground(Color.GRAY.brighter()); \\ renderer.setOpaque(false); \\ renderer.setFont(table.getFont().deriveFont(9f).deriveFont(Font.BOLD)); \\ renderer.setForeground(Color.BLACK); \\ renderer.setBorder(border); \\ return renderer; \\ } \\ textField.setText(value.toString()); \\ return textField; \\ } \\ } \\ } \\ class MyTableModel extends DefaultTableModel \\ { \\ String[][] data = new String[][] \\ { \\ {"", "col 1", "col 2"}, \\ {"row 1", "1", "2"}, \\ {"row 2", "3", "4"}, \\ {"row 3", "5", "6"}, \\ }; \\ public MyTableModel() \\ { \\ } \\ public int getRowCount() \\ { \\ return 4; \\ } \\ public int getColumnCount() \\ { \\ return 3; \\ } \\ public Object getValueAt(int row, int column) \\ { \\ return data[row][column]; \\ } \\ public boolean isCellEditable(int row, int column) \\ { \\ return row != 0 && column != 0; \\ } \\ public Class getColumnClass(int column) \\ { \\ return String.class; \\ }{noformat}{noformat} {noformat}{noformat}     public void setValueAt(Object value, int row, int column) \\ { \\ data[row][column] = value.toString(); \\ } \\ } \\ } \\ {noformat}
{noformat}
{noformat}

Thanks for the suggestion. I noticed that too - too late, had already posted the question.
I need to be able to tab only the editable cells in the table. When I reach the end of the row, tab should focus the first editable cell in the next row.
This code works fine if I remove the last column. However, I need it to work with editable and non-editable fields in a table.
Here is the correct formatted code.
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
public class TableTest extends JFrame {
     public TableTest()
          getContentPane().add(new MyTable());
     public static void main(String[] args)
          TableTest frame = new TableTest();
          frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
          frame.pack();
          frame.setVisible(true);
    public class MyTable extends JTable
        public MyTable()
            super(new MyTableModel());
            putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            setDefaultRenderer(String.class, new Renderer());
            DefaultCellEditor dce = new DefaultCellEditor(new JTextField());
            dce.setClickCountToStart(1);
            setDefaultEditor(String.class, dce);
            setOpaque(false);
            setShowGrid(false);
            configure();
                    private void configure()
            setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            setCellSelectionEnabled(true);
            // Add SelectionListeners to track selection changes
            // across columns.
            getColumnModel().getSelectionModel().addListSelectionListener(
                        new ExploreSelectionListener());
        // Add this class to the body of MyTable class.
        private class ExploreSelectionListener implements ListSelectionListener
            public void valueChanged(ListSelectionEvent e)
                if(!e.getValueIsAdjusting())
                    int row = getSelectedRow();
                    int col = getSelectedColumn();
                                             // Make sure we start with legal values.
                    while(col < 0) col++;
                    while(row < 0) row++;
                    // Find the next editable cell.
                    while(!isCellEditable(row, col))
                        col++;
                        if(col > getColumnCount()-1)
                            col = 1;
                            row = (row == getRowCount()-1) ? 1 : row+1;
                    // Select the cell in the table.
                    final int r = row, c = col;
                    EventQueue.invokeLater(new Runnable()
                        public void run()
                            changeSelection(r, c, false, false);
                    // Edit.
                    if(isCellEditable(row, col))
                        editCellAt(row, col);
                        ((JTextField)editorComp).selectAll();
                        editorComp.requestFocusInWindow();
        private class Renderer implements TableCellRenderer
            DefaultTableCellRenderer renderer;
            JTextField textField;
            protected Border border = new EmptyBorder(1, 1, 1, 1);
            public Renderer()
                renderer = new DefaultTableCellRenderer();
                textField = new JTextField();
                textField.setHorizontalAlignment(SwingConstants.RIGHT);
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
                if (!isCellEditable(row, column))
                    renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                    renderer.setHorizontalAlignment(column == 0 ? SwingConstants.LEFT : SwingConstants.RIGHT);
                    renderer.setBackground(Color.GRAY.brighter());
                    renderer.setOpaque(false);
                    renderer.setFont(table.getFont().deriveFont(9f).deriveFont(Font.BOLD));
                    renderer.setForeground(Color.BLACK);
                    renderer.setBorder(border);
                    return renderer;
                textField.setText(value.toString());
                return textField;
    class MyTableModel extends DefaultTableModel
        String[][] data = new String[][]
                        {"", "col 1", "col 2", ""},
                        {"row 1", "1", "2", "end1"},
                        {"row 2", "3", "4", "end2"},
                        {"row 3", "5", "6", "end3"}
        public MyTableModel()
                    public void setValueAt(Object value, int row, int column)
            data[row][column] = value.toString();
        public int getRowCount()
            return 4;
        public int getColumnCount()
            return 4;
        public Object getValueAt(int row, int column)
            return data[row][column];
        public boolean isCellEditable(int row, int column)
            return  row != 0 && (column != 0 && column != 3);
                    public Class getColumnClass(int column)
            return String.class;
}

Similar Messages

  • Tab between fields when editing song information

    iTunes 10.4 removed the ability to tab between fields when editing song information. Is there another shortcut now?

    Yes, I know EXACTLY what you mean. Actually the Tab sequence was reversed in 10.4. I'm upset that it took me until Septeber 2011 to figure it out. For the longest time, probably every release of iTunes. The Tab sequence went (Source-->Tab-->Search Music box-->Tab-->Tracks List)
    Now it's the reverse and it's so annoying. I have both Mac and Windows and was able to downgrade my Windows iTunes to 10.3.x (though I had to downgrade to a previous iTunes Library.itl file. I cannot downgrade my Mac iTunes b/c it's my main library and I'd lose historic data by restoring and old iTunes Library.itl file
    I've written to Apple about this several times the past few weeks but they've yet to address this. The latest version is 10.5 and it hasn't been restored. I WISH Apple would RESTORE this feature to its ORIGINAL design!!!

  • Editable field in a Adobe Form

    Hi, guys.
    I gotta insert an editable field in an adobe print form, but I can't make it editable.
    I selected 'User Entered- Required' in the 'Value' palette of the field, but, after the launch of the program, it's not editable yet.
    I also tried to valorize the field 'fillable' of an SFPDOCPARAMS-like structure, but this valorization ('X') have stopped the launch of the form.
    Thanks for who will answer me!

    Hi,
    Go to form properties..
    in that click on defaults tab...
    there in preview...change it ro interactive form....
    now check it in pdf preview...
    The preview type affects Designer's preview only, not SAP spool's preview, which
    is always non-interactive (unless, in the ABAP program, you set the fillable
    parameter of function module FP_JOB_OPEN to X or N).
    Thefillable field determines whether a form can have interactive features.
    By default, it cannot. If you set fillable to 'X', interactive features are enabled
    and Adobe Reader grants the so-called Reader rights (in particular, the user
    can enter data and save the form together with the data). If fillable equals
    'N', the user can make entries in the form, but cannot save the form together
    with the entries.
    regards,
    Omkar.
    Message was edited by:
            Omkaram Yanamala

  • Tab Key Navigation in JTable

    Hello All,
    Can anyone please help me with Tab key navigation in a JTable.I
    read all the messages in this group but couldn't implement one.It
    would be a great help if anyone can provide me a working example of how
    to control the tab key in the JTable. I have a JTable with some of the
    columns not editable, I want the focus to be in the first cell and
    whenever the TAB key is pressed, the focus should go to next editable
    cell and select the data in it.For example: if you take a simple table of 4 columns with column 2 not editable, The focus should begin with the first cell(1st column,1st row) and goto (3rd column,1st row) whenever TAB is pressed.It should work in reverse when SHIFT-TAB is pressed.
    I'm new to Java Swing.I would greatly appreciate if anyone can provide me a working example.
    Thanks in advance,
    siddu.

    OK Here is what I have ...
    public class MultipleEditorsPerColumnJTable extends JTable {
    /** Creates a new instance of MultipleEditorsPerColumnJTable */
    public MultipleEditorsPerColumnJTable( int the_column) {
    this.myColumn = the_column;
    this.rowEditors = new ArrayList();
    setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Collections.EMPTY_SET);
    protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,int condition, boolean pressed) {
    boolean isSelected = false;
    if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_TAB,0)) {
    int selRow = getSelectedRow();
    int rowCount = getRowCount();
    int selCol = getSelectedColumn();
    if (selCol == 1) { isSelected= getCellEditor(selRow,selCol).stopCellEditing();}
    int targetRow = (selRow + 1) % rowCount;
    this.editCellAt(targetRow, 1);
    this.getComponentAt(targetRow, 1).requestFocus();
    return super.processKeyBinding(ks,e,condition,pressed);
    I think I know why the requestFocus() is not working. OK, I have a MultipleEditorsPerColumnJTable (sub of JTale), JTextPane, JButton and JLabel. The textpane, label and button have individual editors and renderers. Each time I want to display a new Row, I re-render these components and add it to the table.
    Now with the above code, it still navigates to the next component in the row/ first column in next row depending on the current column. What am I doing wrong?
    Thanks,
    Praveen.

  • Editable JComboBox in JTable

    There is a bug in Jdk1.5 (bug#4684090) - When TAB out from Editable Jcombobox in JTable, the focus is moved to outside JTable instead of next cell.
    What is the best workaround for thsi bug.
    Thanks,
    VJ

    I was using java 1.5.0_06 in my application and I had this problem
    When I upgraded to java 1.6.0_01, I no longer had this issue.
    This seems to be a bug in 1.5 version of Java that has been fixed in 1.6
    thanks,

  • Editable field sprites capture a mouesdown on right click

    I have editable field members and am using buddy to make a
    right click copy/paste menu - problem is that editable field
    sprites seem to think that a rightmousedown is also a left
    mousedown. This completely breaks my behaviour. Anyone ever come
    across this before? I'd rather not replace all my field members
    with text members as thats another pile of re-scripting...
    Thanks

    That is weird! I had never noticed that. It only seems to
    happen if
    the #field member is editable. If the SPRITE is editable
    instead (in
    the Property Inspector on the Sprite tab), then there is no
    problem.
    That should be an easier fix than switching over to #text
    members at least.

  • Slow tabbing between fields

    Hello,
    We have a very complex interactive form with repeating_subforms. We open it binding a large xml file. Tabbing between fields is very slow when we are editing the form.
    We have designed a simple form with one repeating_subform and without scripting. Bindig the same xml file, tabbing between fields is very slow too.
    How can we solve this problem?
    Here are the links to pdf file and to xdp file with the data.
    Thanking you in advance,

    Thank you for answering!
    We are using Livecycle Designer ES4 v 11.0.1 and Acrobat XI pro.

  • Unable to capture context attributes of editable fields

    Hello All,
    In my application, there are two trans. containers. One holds set of material info fields at top and in the bottom the container holds a table with quantity data of the material.
    The material info container has a edit button and 3 fields are editable and saved from the container. In the bottom container there is button to move to next material. Before moving, I check if any data is changed in material info container and display pop up to save it.
    Now, when i click the save button in the mat info container the ediatbel fields data is passed and gets saved. But, when the same save method is called from the confirmation pop up in the bottom container table the editable fields data is not passed. No idea on the reason behind this behaviour.
    The code used to retrieve the data is      
    nd_vipos_mat_master->get_static_attributes(
                IMPORTING
                  static_attributes = lr_vipos_mat_info ).
    Kindly assist.
    Regards,
    Sharath

    Hi ,
    When you are saving data using popup, you must have subscribed an action with popup button. I hope it is not the same action which you are using with SAVE button.
    You can try subscribing the same action for popup which you used in Save button. Ex: if on saving directly, you are calling action "OnSave" and from popup, the triggered action is "OnActionSaveFrom Popup".  So dont use this new action while subscription with popup button. use "OnSave" with popup button also.
    if it is working with save button, it should be fine with popup also.
    Thanks
    Vishal

  • PR Release Strategy tab processor field is not getting displayed

    Hi Experts,
    While creating Purchase Requisition, In the Release Strategy tab processor field is not getting displayed which should be showing the name of the user id which has been configured in the SPRO.
    SPRO--> Rel Proc for PR > Rel Group> Rel Code--> Object type (US) and --> Agent (User id who has to approve the PR).
    release strategy - Release code  -work flow 1
    That processer name is not displaying
    Thanks
    chandoo

    This is the workflow forum.

  • Editable fields in oracle report

    Hi,
    I am hoping someone can help what I am trying to create is a PDF oracle report with an editable field at the end of the report. The user would use this field to type comments about the report and then save the file with the comments attached.
    I did a search but couldn't really find anything relevant apart from this thread here: Re: How to add to report in pdf format editable fields but it looks like that was never answered.
    Users have access to Adobe Acrobat so an alternative solution could be just to create a rectangle and tell the users to write in that but it is not an ideal solution.
    If it is not possible in oracle reports we are also licensed for BI Publisher but as of yet I haven't been able to find anything that would do this using that tool either.
    Regards,
    Chad

    with an editable field at the end of the report.In Reports the user cannot add text after generation of the report. So, do it before generating the report. Add a parameter p_comment to the data model and add this to the parameter form (or whatever form you use to call the report, e.g. from Forms) and create a text field at the end of the report.

  • To capture the selected rows along with edited field contents in alv report

    Dear All,
             I do have requirement where, in alv report output one field is editable and need to save the content of the edited field along with the selected rows.
             For example If there are 10 records displayed in the alv output with 20 fields.
    Out of this 20 fields one field (say XYZ) is editable. Also i have already created a new pushbutton (say ABC) on alv output. Now in the alv output if we maintain some value in the field (XYZ ) for the 2nd and 4th record and select this two records, and when clicked on the pushbutton (ABC) it has to update the DB table.
          I am using the Func Module  'REUSE_ALV_GRID_DISPLAY'. 
          Your early reply with sample code would be appreciated.
    Thanks in Advance.

    HI Naveen ,
    There is an import parameter "i_callback_program" in the function module,
    plz pass the program name to it.
    Capture the command by passing a field of type sy-ucomm to "I_CALLBACK_USER_COMMAND ".  Check the returned command and
    and program a functionality as desired.
    u can try the event double_click or at line selection. there u can use READLINE command to c if the line has been selected.
    In case it is , process the code segment.
    Regards
    Pankaj

  • EDIT field in ALV GRID and on SAVE it has to update the DB Table

    Hi Experts,
    I have searched lot of forums...
    But i had not got the exact solution for this...
    I have multiple records that displayed in the ALV output screen and i had modified more than one record and then click on save.
    It has to modify all the lines that i had changed in the EDITABLE FIELD.
    Can any one help me in doing so...
    Sample code will be more help full....
    Thanks in advance,
    Kruthik

    Hi Kruthik
    Check [=> OO ALV Event DATA_CHANGED <= |http://abaptips.com/?p=70], hope you will get idea.
    Please reply in case of any confusion.
    Thanks and Best Regards,
    Faisal

  • Editable field in alv

    hiii
    when doing editable field in alv
    you set
    i_fieldcat-edit = C_X
    i_fieldcat-input = C_X
    P_selfield-refresh = C_X
    this is not working when i click on save the internal table is not keeping the change i have edit on the screen and the p_selfield value also has still the old value.
    but when i double click the p_selfield is keeping the editable value.  Please advise ??

    hi,
    Check out this sample program.The part for 'EDIT' is in Bold..
    report  zalv_color_display_edit.
    type-pools: slis.
    tables : zcust_master2.
    types : begin of wi_zcust_master2,
            zcustid like zcust_master2-zcustid,
            zcustname like zcust_master2-zcustname,
            zaddr like zcust_master2-zaddr,
            zcity like zcust_master2-zcity,
            zstate like zcust_master2-zstate,
            zcountry like zcust_master2-zcountry,
            zphone like zcust_master2-zphone,
            zemail like zcust_master2-zemail,
            zfax like zcust_master2-zfax,
            zstat like zcust_master2-zstat,
            field_style  type lvc_t_styl,
    end of wi_zcust_master2.
    data: it_wi_zcust_master2 type standard table of wi_zcust_master2
                                                     initial size 0,
          wa_zcust_master2 type wi_zcust_master2.
    data: fieldcatalog type slis_t_fieldcat_alv with header line.
    data: it_fieldcat type lvc_t_fcat,    
          wa_fieldcat type lvc_s_fcat,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type lvc_s_layo,     "slis_layout_alv,
          gd_repid     like sy-repid.
    start-of-selection.
      perform data_retrieval.
      perform set_specific_field_attributes.
      perform build_fieldcatalog.
      perform build_layout.
      perform display_alv_report.
    form build_fieldcatalog.
      wa_fieldcat-fieldname   = 'ZCUSTID'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER ID'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCUSTNAME'.
      wa_fieldcat-scrtext_m   = 'CUSTOMER NAME'.
      wa_fieldcat-col_pos     = 1.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZADDR'.
      wa_fieldcat-scrtext_m   = 'ADDRESS'.
      wa_fieldcat-col_pos     = 2.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCITY'.
      wa_fieldcat-scrtext_m   = 'CITY'.
      wa_fieldcat-col_pos     = 3.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTATE'.
      wa_fieldcat-scrtext_m   = 'STATE'.
      wa_fieldcat-col_pos     = 4.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZCOUNTRY'.
      wa_fieldcat-scrtext_m   = 'COUNTRY'.
      wa_fieldcat-col_pos     = 5.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZPHONE'.
      wa_fieldcat-scrtext_m   = 'PHONE NUMBER'.
      wa_fieldcat-col_pos     = 6.
    wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZEMAIL'.
      wa_fieldcat-scrtext_m   = 'EMAIL'.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable  wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZFAX'.
      wa_fieldcat-scrtext_m   = 'FAX'.
      wa_fieldcat-col_pos     = 8.
      wa_fieldcat-edit        = 'X'. "sets whole column to be editable
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
      wa_fieldcat-fieldname   = 'ZSTAT'.
      wa_fieldcat-scrtext_m   = 'STATUS'.
      wa_fieldcat-col_pos     = 9.
      append wa_fieldcat to it_fieldcat.
      clear  wa_fieldcat.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
    Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    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'
      call function 'REUSE_ALV_GRID_DISPLAY_LVC'
        exporting
          i_callback_program = gd_repid
          is_layout_lvc      = gd_layout
          it_fieldcat_lvc    = it_fieldcat
          i_save             = 'X'
        tables
          t_outtab           = it_wi_zcust_master2
        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
          text
    -->  p1        text
    <--  p2        text
    form data_retrieval .
      data: ld_color(1) type c.
      select zcustid zcustname zaddr zcity zstate zcountry zphone zemail
    zfax zstat up to 10 rows from zcust_master2 into corresponding fields of
    table it_wi_zcust_master2.
    endform.                    "data_retrieval
    *&      Form  set_specific_field_attributes
          populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      data ls_stylerow type lvc_s_styl .
      data lt_styletab type lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The following code sets it to be disabled(display only) if 'ZFAX'
    is NOT INITIAL.
      loop at it_wi_zcust_master2 into  wa_zcust_master2.
        if  wa_zcust_master2-zfax is not initial.
          ls_stylerow-fieldname = 'ZFAX' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                          "set field to disabled
          append ls_stylerow  to  wa_zcust_master2-field_style.
          modify it_wi_zcust_master2  from  wa_zcust_master2.
        endif.
      endloop.
    endform.                    "set_specific_field_attributes
    Hope this helps you,
    Arunsri

  • Editable field in ALV does not accept negative sign values

    Hi guys,
    We have an editable field in ALV but it does not accept negative sign,,, it is causing an error... We need to input a negative value in that editable field...
    How to handle this?
    Thanks!

    Hi Mark,
      This topic has been just discussed at this thread:
    Problem with OO ALV
    Regards,
    Chandra Sekhar

  • Editable field in alv tree output using cl_gui_alv_tree

    Hi,
    i need Editable field with F4 help in alv tree output using cl_gui_alv_tree.
    regards,
    Naresh

    sadly, this is not possible. An ALV Tree cannot by editable.
    Regards

Maybe you are looking for

  • Ipod touch 2nd gen won't connect to wifi/internet

    I have an Ipod gen 2 and I recently stopped using it for about a month. I turned it back on to find NO way to get it to connect to the wifi. I have restarted my device several times as well as my router/modem, and I have restored network settings. It

  • Assign global array of structures of structures of std strings in a dll

    I have a dll which consists of three c files. Find bellow the c file of the loader and the three files of the dll. In dll, file 1 and file 2 are almost identical, static arrays names and sizes, structure names, Prepare_1() and Prepare_2() functions.

  • When does a  message be acknowledged actually

    How Can a message be acknowledged Say that i had created a QueueSession using the QueueSession createQueueSession(true,client_acknowledge) If i post a Message , please tell me when does it gets acknowledged ?? Either 1. When Successfully Posted to Th

  • How to define interface builder outlets in Cocoa-Python?

    Hi, I am writing a Cocoa-Python application but I couldn't find a way to define outlets in Python code that I can use in the Interface Builder. Of course I know how to do that in Objective-C and this doc http://developer.apple.com/documentation/Cocoa

  • How can i create a multilingual website with a menu for each one?

    I have all the pages in spanish and the same pages in english ej. Contacto and Contact ...should be sister or child pages? I need two diferent menus (one for spanish pages master, another menu for the english pages master) but the menu feature mixes