Edit Field with button (...)

I'm beginner in Java. I'd like a cell in a table with a button (...) on the right side to open a Dialogbox (FileDialog to put a filename in the cell). Thank you in advance for any help.
Regards
Museti

Hi
I have tried the codes below but can't get it right. Could you tell me what is going wrong here? Thanks.
//MyTableCellRenderer
package testrenderer;
import javax.swing.UIManager;
import java.awt.*;
public class MyTableCellRenderer {
boolean packFrame = false;
/**Die Anwendung konstruieren*/
public MyTableCellRenderer() {
FrameCellRenderer frame = new FrameCellRenderer();
//Frames �berpr�fen, die voreingestellte Gr��e haben
//Frames packen, die nutzbare bevorzugte Gr��eninformationen enthalten, z.B. aus ihrem Layout
if (packFrame) {
frame.pack();
else {
frame.validate();
//Das Fenster zentrieren
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
/**Main-Methode*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception e) {
e.printStackTrace();
new MyTableCellRenderer();
// FrameCellRenderer.java
package testrenderer;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameCellRenderer extends JFrame
implements MyTableData
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu();
JMenuItem jMenuFileExit = new JMenuItem();
JMenu jMenuHelp = new JMenu();
JMenuItem jMenuHelpAbout = new JMenuItem();
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JTable jTable1 = new JTable(DATA, COLHEADS);
BrowseButtonEditor be = new BrowseButtonEditor();
/**Den Frame konstruieren*/
public FrameCellRenderer() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
/**Initialisierung der Komponenten*/
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(FrameCellRenderer.class.getResource("[Ihr Symbol]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Table Cell Renderer");
jMenuFile.setText("Datei");
jMenuFileExit.setText("Beenden");
jMenuFileExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuFileExit_actionPerformed(e);
jMenuHelp.setText("Hilfe");
jMenuHelpAbout.setText("Info");
jMenuHelpAbout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jMenuHelpAbout_actionPerformed(e);
jPanel1.setLayout(borderLayout2);
jMenuFile.add(jMenuFileExit);
jMenuHelp.add(jMenuHelpAbout);
jMenuBar1.add(jMenuFile);
jMenuBar1.add(jMenuHelp);
contentPane.add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(jTable1, null);
this.setJMenuBar(jMenuBar1);
jTable1.getColumn("URL").setCellRenderer(new BrowseButtonRenderer());
jTable1.getColumn("URL").setCellEditor(new BrowseButtonEditor());
/**Aktion Datei | Beenden durchgef�hrt*/
public void jMenuFileExit_actionPerformed(ActionEvent e) {
System.exit(0);
/**Aktion Hilfe | Info durchgef�hrt*/
public void jMenuHelpAbout_actionPerformed(ActionEvent e) {
/**�berschrieben, so dass eine Beendigung beim Schlie�en des Fensters m�glich ist.*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
jMenuFileExit_actionPerformed(null);
// MyTableData.java
public interface MyTableData {
public static final String[][] DATA = {
{"Vertrag 01","c:\\vertrag\\deutsch\\vertrag01.htm"},
{"Vertrag 02","c:\\vertrag\\deutsch\\vertrag02.htm"},
{"Vertrag 03","c:\\vertrag\\franz�sisch\\vertrag03.htm"},
{"Vertrag 04","c:\\vertrag\\franz�sisch\\vertrag04.htm"}
public static final String[] COLHEADS = {
"Bezeichnung", "URL"
// BrowseButtonEditor.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class BrowseButtonEditor
extends AbstractCustomCellEditor
     private BrowseButtonRenderer br;
     public BrowseButtonEditor()
          br = new BrowseButtonRenderer("...");
          this.addMouseListenerToLabel();
     public BrowseButtonEditor(String title)
          br = new BrowseButtonRenderer(title);
          this.addMouseListenerToLabel();
     public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected,
                                                  int row, int column)
          JButton button = br.getButton();
button.setText("...");
          String sStr = new String(((String)value));
setCellEditorValue(sStr);
JLabel label = br.getLabel();
label.setText(sStr);
          return br;
     public boolean stopCellEditing()
          JButton button = br.getButton();
JLabel label = br.getLabel();
          setCellEditorValue(new String(label.getText()));
          return super.stopCellEditing();
     private void addMouseListenerToLabel()
          br.getLabel().addMouseListener(new MouseAdapter()
                    public void mousePressed(MouseEvent e)
                         if (e.getClickCount() == 2)
                              cancelCellEditing();
// BrowseButtonRenderer.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.TableCellRenderer;
public class BrowseButtonRenderer
extends JPanel implements
TableCellRenderer
     private BorderLayout borderLayout1 = new BorderLayout();
     private JLabel label = new JLabel();
     private JButton button = new JButton();
     public BrowseButtonRenderer()
          this.setSize(40, 40);
          this.setLayout(borderLayout1);
          button.setPreferredSize(new Dimension(40, 30));
          this.add(label, BorderLayout.NORTH);
          this.add(button, BorderLayout.EAST);
          label.setHorizontalAlignment(JLabel.LEFT);
          label.setHorizontalTextPosition(JLabel.LEFT);
          // add change listener to button
          button.addChangeListener(new ChangeListener()
                    public void stateChanged(ChangeEvent e)
                         label.setText("" + button.getValue());
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button_actionPerformed(e);
     public BrowseButtonRenderer(String title)
          this();
button.setText(title);
     public Component getTableCellRendererComponent(JTable table, Object value,
                                                  boolean isSelected, boolean hasFocus, int row, int column)
          String v = (String)value;
          String sStr = (String)value;
          label.setText(sStr);
          button.setEnabled(isSelected);
          label.setEnabled(isSelected);
          label.setBackground(isSelected && hasFocus ? table.getSelectionBackground() : table.getBackground());
          button.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
label.setBackground(Color.white);
          this.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());
          this.setForeground(isSelected && hasFocus ?     table.getSelectionBackground() : table.getBackground());
          this.setFont(table.getFont());
          return this;
     public JButton getButton()
          return button;
     public JLabel getLabel()
          return label;
void button_actionPerformed(ActionEvent e)
JFileChooser datei = new JFileChooser();
String sFile = new String("");
int returnVal = datei.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION)
sFile = datei.getSelectedFile().getName();
System.out.println("You chose to open this file: " + sFile);
label.setText(sFile);
// AbstractCustomCellEditor.java
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import javax.swing.tree.*;
import java.awt.event.MouseEvent;
import java.util.EventObject;
* <P>
* This abstract class can be extended in order to customize the look and
* feel of the editor for a table cell. This will allow the use of any type
* of component (i.e. JComboBox, JSlider, JCheckBox, or other custom renderers)
* </P>
* <P>
* This class uses and EventListenerList to maintain a list of CellEditorListeners
* and provides two protected methods for firing editing-stopped and editing-canceled
* events to listeners.
* </P>
* <P>
* This class also maintains an Object reference that represents the editor's value.
* In addition to implementing the TableCellEditor.getCellEditorValue() method, this
* class also provides a setter method for this value - setCellEditorvalue(Object value)
* </P>
* <P>
* This class, like DefaultCellEditor, provides a clickCountToStart property that
* specifies the number of mouse clicks required to initiate editing.
* </P>
* <P>
* This class defines a cell to be editable if the event passed to
* isCellEditable() is a mouse event and the click count is equal to (or greater than)
* the clickCountToStart.
* </P>
* <P>
* This class also defined all cells to be selectable.
* </P>
* <P>
* The stopCellEditing and cancelCellEditing methods fire appropriate events, and
* stopCellEditing returns true, indicating that editing was stopped.
* </P>
* <P>
* Important Note: This class leaves the getTableCellEditorComponent method defined
* by TableCellEditor unimplemented. Extensions of this class MUST implement
* getTableCellEditorComponent().
* </P>
* <P>
* Note: This code was extracted and modified from:
* Graphic Java 2 - Mastering the JFC vol. II: Swing (3rd. ed)
* by: David M. Geary
* ISBN: 0-13-079667-0
* Chapter 19: Tables
* AbstractCellEditor
* </P>
* <P>
* @author A. Timpone
abstract class AbstractCustomCellEditor implements TableCellEditor
     protected EventListenerList listenerList = new EventListenerList();
     protected Object value;
     protected ChangeEvent changeEvent = null;
     protected int clickCountToStart = 1;
     * This method returns tha value (as an Object) stored within
     * the editor
     * @return The Object representation of the editor's value
     public Object getCellEditorValue()
          return value;
     * This method is used to set the value of the editor
     * @param value The value you wish to set the editor component to
     public void setCellEditorValue(Object value)
          this.value = value;
     * This method is used to control the number of mouse clicks required to invoke
     * the editor
     * @count Defaulted to 1, this is the number of clicks you wish performed to invoke the editor
     public void setClickCountToStart(int count)
          clickCountToStart = count;
     * The method returns the number of clicks required to invoke the editor
     * @return The number of mouse clicks required to invoke the editor
     public int getClickCountToStart()
          return clickCountToStart;
     * This method determines if a cell extending this class is editable based on
     * the type of event performed on the cell. If this event is of type MouseEvent,
     * it will invoke the editor if the correct number of clicks is performed
     * @param anEvent The type of event being performed on the cell
     * @return true of false indicating the cell is editable
     public boolean isCellEditable(EventObject anEvent)
          if (anEvent instanceof MouseEvent)
               if (((MouseEvent)anEvent).getClickCount() < clickCountToStart)
                    return false;
          return true;
     * This method determines if the cell should be selected.
     * By default, this method returns true
     * @param anEvent The type of event being performed on the cell
     * @return true of false indicating the cell is selected (Default to true)
     public boolean shouldSelectCell(EventObject anEvent)
          return true;
     * This method executed the TableCellEditor.fireEditingStopped() method
     * indicating that editing on the current cell has stopped
     * @return true or false indicating cell editing has stopped (Default to true)
     public boolean stopCellEditing()
          fireEditingStopped();
          return true;
     * This method executed the TableCellEditor.fireEditingCanceled() method
     * indicating that editing on the current cell has been canceled
     public void cancelCellEditing()
          fireEditingCanceled();
     * This method adds a CellEditorListener to the cell entending this class.
     * This listener is added into the listener list
     * @param l This is the CellEditorListener you wish to add to the specific cell
     public void addCellEditorListener(CellEditorListener l)
          listenerList.add(CellEditorListener.class, l);
     * This method removes a CellEditorListener from the cell entending this class.
     * This listener is removed from the listener list
     * @param l This is the CellEditorListener you wish to remove from the specific cell
     public void removeCellEditorListener(CellEditorListener l)
          listenerList.remove(CellEditorListener.class, l);
     * This method loops through all of the listeners within the listenerList
     * and calls the appropriate editingStopped() method passing in the
     * ChangeEvent
     protected void fireEditingStopped()
          Object[] listeners = listenerList.getListenerList();
          for (int i = listeners.length-2; i>=0; i-=2)
               if (listeners[i] == CellEditorListener.class)
                    if (changeEvent == null)
                         changeEvent = new ChangeEvent(this);
                    ((CellEditorListener)listeners[i+1]).editingStopped(changeEvent);
     * This method loops through all of the listeners within the listenerList
     * and calls the appropriate editingCanceled() method passing in the
     * ChangeEvent
     protected void fireEditingCanceled()
          Object[] listeners = listenerList.getListenerList();
          for (int i = listeners.length - 2; i >= 0; i -= 2)
               if (listeners==CellEditorListener.class)
                    if (changeEvent == null)
                         changeEvent = new ChangeEvent(this);
                    ((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent);

Similar Messages

  • Editable field with F4 help 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

    Hi Naresh,
    Pass the field catalog with the additional parameter (ls_fcat-edit = 'X'.).
    for F4 help if the data element have the search help it automatically will come. other wise include the additional parameter in the field catalog (ls_fcat-F4AVAILABL = 'X')
    Reward if found helpful.
    Regards,
    Boobalan Suburaj

  • Does anyone know why I cant save (dnloaded) form to edit fields with Cute PDF Writer?

    Please Help!!  I am trying to get stuff out to a customer, and I have to keep re-entering information each time.........For some reason after I download a form and complete the fields from internet,  I PRINT/SAVE to Adobe Cute PDF Writer.  Later when I open the file from harddrive I am unable to edit the fields....But I notice even after saving to the Writer,  it automatically opens as reader not writer.   I have tried to associate to the Writer but I cant find it, although I know its on my computer it isnt under program files. 
    My main question - Before I go through the trouble of reinstall, does cute PDF Writer actually allow edits or do I have to get a real PDF writer?
    So if the software does allow editing forms, is it maybe just not fully loaded, and should I reinstall the Cute PDF Writer???? Id appreciate any ideas at this point, this has caused alot of wasted time so far....

    Go to the Acrobat forum here to discuss PDF form creation and editing with Adobe's own Acrobat products. CutePDF Writer, created by another company, only writes PDF. It cannot create or edit forms.

  • Input in fields with buttons like calculator

    Hello,
    i have an dynpro inputfield and i want to make a on screen keyboard, so that i can write in it without a real keyboard.
    Is that possible that when i push my buttons that the input is made in realtime in that inputfield?
    Thanks

    I want to click in one of the two input fields on the left and then i want to insert my input with my buttons on the right.
    And when i click in the secoond input field i want to fill that with my button input
    Regards

  • ALV Edit Field with error

    Hi!
    I'm trying to enter data into a few fields of my ALV but when I press save or double click or try to do any action I'm getting and error and I can't go into my gode to get the data and save it into my tables.
    I declarated my ALV table like
    DATA BEGIN OF it_output OCCURS 0.
    DATA:
    kunag    TYPE s901-kunag,
    zbuilder TYPE s901-zbuilder,
    kunnr    TYPE s901-kunnr,
    zdepbal  TYPE s901-zdepbal,
    zdepret  TYPE s901-zdepret,
    zretbal  TYPE s901-zretbal,
    zretret  TYPE s901-zretret,
    zdepadj  TYPE s901-zdepadj,
    zretadj  TYPE s901-zretadj,
    zdisdel  TYPE s901-zdisdel,
    zchpdel  TYPE s901-zchpdel,
    fields to be filled
    returned TYPE s901-zdepbal,
    scrapped TYPE s901-zdepbal,
    comments(30),
    bstkd    TYPE bstkd,
    trmtyp   TYPE trmtyp,
    werks    TYPE werks,
       END OF it_output.
    the last 6 fields are the ones that I need to fill.
    The error that I'm getting is into a pop up and it says :
    Field T_output_trmtyp is not in the apab dictionary.
    Did someone has this problem before? I'll keep looking for the solution.
    thanks.

    Hi,
    Long time back I faced a little similar kind of error. But not exactly for this scenario. I don't remember what the issue was but it was solved when I changed the variable type declaration. I mean, earlier I had declared it as
    werks TYPE werks_d.
    But later I changed it as
    werks LIKE T001W-werks.
    And this solved my problem. Hope this may help u...

  • Linking Editing TextArea with Button Handler

    Java newbie here,i am trying to create a program to display a keyboard on screen and display the the letter in a text area when the character letter is pressed. And the complete sentence when return is pressed.
    I have the GUI up, the problem is the letters are dispayed in a JOptionPane and i want them to be written to the TextArea.
    Any help would be appreaciated
    Here is the code in full so far.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    * Alphabet is a program that will display a text pad and 27 buttons of the 25
    * Letters of the Alphabet and display them when pressed and display all buttons
    * when Return button is pressed..
    * version (V 0.1)
    public class Alphabet extends JFrame
        private JPanel buttonPanel  ;
        private JButton buttons[];
        private JButton SpaceButton;
        private JButton ReturnButton;
        //setup GUI
        public Alphabet()
        super("Alphabet");
        //get content pane
        Container container = getContentPane();
        //create button array
        buttons = new JButton[122];
        //intialize buttons
        SpaceButton = new JButton ("Space");
        ReturnButton = new JButton ("Return");
        //setup panel and set its layout
        buttonPanel = new JPanel();
        buttonPanel.setLayout(new GridLayout (7,buttons.length));
        //create text area
        JTextArea TextArea = new JTextArea ();
       TextArea.setEditable(false);
       container.add(TextArea, BorderLayout.CENTER);
       // set a nice titled border around the TextArea
        TextArea.setBorder(
          BorderFactory.createTitledBorder("Your Text is Displayed Here"));
      //create and add buttons
        for (int count = 96; count <buttons.length; count++ ) {
        buttons[count] = new JButton( ""+ (char)(count +1 ));
        buttonPanel.add(buttons [count]);
        ButtonHandler handler = new ButtonHandler();
        buttons[count].addActionListener(handler);
        buttonPanel.add(SpaceButton);
       buttonPanel.add(ReturnButton);
       ReturnButton.setToolTipText( "Press to Display Sentence" ); 
         container.add(buttonPanel, BorderLayout.SOUTH);
        // set a nice titled border around the ButtonPanel
        buttonPanel.setBorder(
          BorderFactory.createTitledBorder("Click inside this Panel"));
            // create an instance of inner class ButtonHandler
              // to use for button event handling              
              ButtonHandler handler = new ButtonHandler(); 
              ReturnButton.addActionListener(handler);
            setSize (625,550);
            setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
        Alphabet application = new Alphabet();
        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
         private class ButtonHandler implements ActionListener {
              // handle button event
             public void actionPerformed( ActionEvent event )
                 JOptionPane.showMessageDialog( Alphabet.this,
                    "You pressed: " + event.getActionCommand() );
    }//END CLASS ALPHABET

    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class Alphabet extends JFrame
    private JPanel buttonPanel ;
    private JButton buttons[];
    private JButton SpaceButton;
    private JButton ReturnButton;
    JTextArea TextArea;
    String str="";String stt="";
    //setup GUI
    public Alphabet()
    super("Alphabet");
    //get content pane
    Container container = getContentPane();
    //create button array
    buttons = new JButton[122];
    //intialize buttons
    SpaceButton = new JButton ("Space");
    ReturnButton = new JButton ("Return");
    //setup panel and set its layout
    buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout (7,buttons.length));
    //create text area
    TextArea = new JTextArea ();
    TextArea.setEditable(false);
    container.add(TextArea, BorderLayout.CENTER);
    // set a nice titled border around the TextArea
    TextArea.setBorder(
    BorderFactory.createTitledBorder("Your Text is Displayed Here"));
    //create and add buttons
    for (int count = 96; count <buttons.length; count++ ) {
    buttons[count] = new JButton( ""+ (char)(count +1 ));
    buttonPanel.add(buttons [count]);
    ButtonHandler handler = new ButtonHandler();
    buttons[count].addActionListener(handler);
    buttonPanel.add(SpaceButton);
    buttonPanel.add(ReturnButton);
    ReturnButton.setToolTipText( "Press to Display Sentence" );
    container.add(buttonPanel, BorderLayout.SOUTH);
    // set a nice titled border around the ButtonPanel
    buttonPanel.setBorder(
    BorderFactory.createTitledBorder("Click inside this Panel"));
    // create an instance of inner class ButtonHandler
    // to use for button event handling
    ButtonHandler handler = new ButtonHandler();
    ReturnButton.addActionListener(handler);
    SpaceButton.addActionListener(handler);
    setSize (625,550);
    setVisible(true);
    }// end constructor Alphabet
    public static void main (String args[])
    Alphabet application = new Alphabet();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // inner class for button event handling
    private class ButtonHandler implements ActionListener {
    // handle button event
    public void actionPerformed( ActionEvent event )
              if((event.getActionCommand()).equals("Space")){
                   TextArea.setText(event.getActionCommand());
                   str+=" ";
                   //TextArea.append(" ");
              else if((event.getActionCommand()).equals("Return")){
                   stt+=str;
                   stt+="\n";
                   str="";
                   TextArea.setText(stt);
                   //TextArea.append(str);
                   //TextArea.append("\n");
              else {
                   TextArea.setText(event.getActionCommand());
                   str+=event.getActionCommand();
                   //TextArea.append(event.getActionCommand());
    }//END CLASS ALPHABET
    Ok?

  • 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

  • Error when trying to set a date type edit field

    Hi all
    I have an edit text field in a form which is bounded to a date type
    database field using dbDataSource.
    When i try to set the edit text field value with Today's date by code.
    I recieve an error message that the value which
    i'm trying to set is not legal. the  error number is [131-183].
    I use the following code to set the edit field:
    If oEditText.Value.Trim = String.Empty Then
                Dim strDate As String
                Dim sboBob As SAPbobsCOM.SBObob =
                 oCompany.GetBusinessObjec(SAPbobsCOM.BoObjectTypes.BoBridge)
                 rs = sboBob.Format_DateToString(Microsoft.VisualBasic.Today)
               strDate = rs.Fields.Item(0).Value.ToString().Trim()
    Try 
           oEditText.Value = strDate
    Catch ex As Exception
        SBO_Application.MessageBox("error setting
    current date: " & ex.Message)
    End Try
    End If
    My question is how can i set the edit field with a valid value?

    Hi!
    When writing to EditText.Value you must always use the B1 "DB-Format" as String.
    The following examples are assuming (it's a must!) that the EditText-Fields are bound to a corrosponding DataSource (Type Date, Price etc...)
    MyDateEditTxt.Value="20080207"
    MyPriceEditTxt.Value="1341.79"
    The best of it: It's Windows and SBO-GUI-Language independent.
    EditText.String must always be written with the format of the actual Language of the SBO-GUI, which can be changed by the user....
    You may also have a look at my statements regarding these problems near the end of this thread:
    [How to pass date value to an UDF;
    Cheers,
    Roland

  • How to get Length of Editable Field greater than 10 using ALV_GRID_DISPLAY

    Hi Experts,
    I am Using , REUSE_ALV_GRID_DISPLAY_LVC For Displaying  an ALV Report .
    Now i'm Using Few fields in Editable mode , but the problem is that , the length of those, editable fields is restricted only to 10 characteras.
    But i need a editable  field with length of 20 chars , ,for, entering some remarks..Is it possible ?
    Can anyone, help how to do that ..?
    Thanx in Advance .. 
    Regards,
    Rajesh

    you can make use of INTLEN
    set the value to 20 and then you can enter to 20 chars.
    FIELDCAT-INTLEN = 20.
    FIELDCAT-OUTPUTLEN = 20.

  • ALV  issue - capturing user changes in editable fields using custom button?

    Hi,
    I created a custom button in ALV tool bar.   And also in my ALV grid I have couple of fields Editable option. User can change values for these 2 fields.
    My question is -
    After changing values for these editable fields(more than 1 record)  , user will click on custom button and then I have to update all the user changed values in to my internal table(lt_tab)  and then I have to process logic.
    Problem is when user click on Custom button in ALV tool bar it is not having the changed values in lt_tab table.
    Only when user clicks  some thing on ALV grid records or fields then it is getting all the changed values in to lt_tab.
    Can any one tell me how I can get changed values when user clicks on custom button?
    1. Can we place custom button in ALV Grid? instead of ALV tool bar? 
    or
    How I can capture user changes when they click on custom button?
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    TABLES
          T_OUTTAB                          = lt_tab
    Please check this logic-
    CASE r_ucomm.
        WHEN '&IC1'.
    - It_tab  having all changed field values
      WHEN 'custom button'.
          lt_tab  - not having any changed values - showing all initial lt_tab values.
    I highly appreciate your answers on this.
    Thanks.
    Rajesh.

    Hi,
    Use this code, its working:-
    *&      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                = v_rep_id       " report id
         i_callback_pf_status_set          = 'PF'           " for PF-STATUS
         i_callback_user_command           = 'USER_COMMAND' " for 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      " for layout
         it_fieldcat                       = it_field       " field catalog
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
         it_sort                           = it_sort        " sort info
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
         i_save                            = 'A'
         is_variant                        = wa_variant     " variant name
    *     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      " internal table
       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
    *&      Form  USER_COMMAND
    *       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
    *       AND EXECUTE THE APPROPIATE CODE
    *      -->LV_OKCODE   used to capture the function code
    *                     of the user-defined push-buttons
    *      -->L_SELFIELD   text
    FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
    * assign the function code to variable v_okcode
      lv_okcode = sy-ucomm.
    * handle the code execution based on the function code encountered
      CASE lv_okcode.
    * when the function code is EXECUTE then process the selected records
        WHEN 'EXECUTE'. "user-defined button
    * to reflect the data changed into internal table
          DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
          IF ref_grid IS INITIAL.
            CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
              IMPORTING
                e_grid = ref_grid.
          ENDIF.
          IF NOT ref_grid IS INITIAL.
            CALL METHOD ref_grid->check_changed_data.
          ENDIF.
    * refresh the ALV Grid output from internal table
          l_selfield-refresh = c_check.
      ENDCASE.
    ENDFORM.
    This will reflect all the changes in the internal table. Now you can include your logic as per your requirement.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir

  • Grid is coming with the row having editable field

    hello,
    I ahve to display OO ALV grid after checking a check box in selection screen , after selecting a row and pressing on edit button in application tool bar it has to give edit option for a field in the row which user has selected, after pressing save button (pop up for confirmation has been given here )data has to get update in ztable and the same has to be reflected in the current grid ...... TILL HERE EVERY THING IS WORKING FINE.
    If the user selects particular record and press the EDIT button, ( assume he didn't edited any thing and he didn't press the save button also )  immediately if he presses the BACK button it should go to selection screen ( this part is working) again if he presses execute button in selection screen ---> grid is coming with the row having editable field (WHICH I DONT WANT).

    Hi,
    You can code as below...
    WHEN 'BACK3'.
    perform check_save_BEFORE.
    "refresh the internal tables used for Selection process and display and also refresh the internal tables used in methods.
    LEAVE TO SCREEN 0..
    Try it.
    Thanks
    Arbind

  • 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

  • Interactive report with checkbox and editable field

    Hi,
    For a project I'm working on I need to create a interactive report in Apex 3.2 with the ability to select lines and to modify one of the columns in the report.
    To do this, I started off by adding these two fields to the selection query of my IR:
    apex_item.checkbox(1, product_number) cb
    and
    apex_item.text (2,QTY_TO_ORDER) QTY_TO_ORDER
    cb is the checkbox files, and QTY_TO_ORDER is the editable field.
    That worked like a charm and I got my two fields in the report.
    To process the values, I added this page process, wich for now should only store the "product number" and "QTY_TO_ORDER" fields in a table.
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.count LOOP
    insert into mytmptable values (APEX_APPLICATION.G_F01(i),APEX_APPLICATION.G_F02(i));
    END LOOP;
    commit;
    end;
    However, this doesn’t work the way I want it to work. When I check the checkboxes of two rows, it will store two rows with the right product numbers, but it will take the top two QTY_TO_ORDER field of the table regardless of which ones are checked. I was able to solve this problem, by adding a rownum to the query and using the rownum as the value for the checkbox. Since I still need the product_number and qty_to order fields I made them both text fields.
    I changed my page process to:
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.count LOOP
    insert into mytmptable values (APEX_APPLICATION.G_F02(APEX_APPLICATION.G_F01(i)),
    APEX_APPLICATION.G_F03(APEX_APPLICATION.G_F01(i)));
    END LOOP;
    commit;
    end;
    This seemed to solve the problem, and I now got the right values in the table, unless I used sorting in the report... As soon as I sorted the report in a way different than by rownum, I got the wrong values in the table. The reason for this is of course that my insert just selects the nTh row from the table, and my rownums aren't dynamic.
    I've found a lot of examples on the internet using '#ROWNUM#' in the selection, which should dynamically generate a rownum in the report. This seems to work in normal report, but in a interactive reports, the literal values '#ROWNUM#' shows up.
    Is there any way to solve this issue?

    Hi,
    Try with 3 fields:
    apex_item.checkbox(1, product_number) cb,
    apex_item.text (2,QTY_TO_ORDER) QTY_TO_ORDER,
    apex_item.hidden(3, product_number) prod_no
    The hidden field should be display as a hidden column.
    Then your process can be:
    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.count LOOP
    FOR j in 1..APEX_APPLICATION.G_F03.count LOOP
    IF APEX_APPLICATION.G_F01(i) = APEX_APPLICATION.G_F03(j)) THEN
    insert into mytmptable values (APEX_APPLICATION.G_F01(i),APEX_APPLICATION.G_F02(j));
    exit;
    END IF;
    END LOOP;
    END LOOP;

  • I have problems with seeing my bookmarks, file, view, edit...buttons. I tried other shortcuts. I noticed that all of my bookmarks are located in the Internet Explorer browsers, how can I restore setting back to Mozilla Firefox?

    I have problems with seeing my bookmarks, file, view, edit...buttons. I tried other shortcuts. I noticed that all of my bookmarks are located in the Internet Explorer browsers, how can I restore setting back to Mozilla Firefox?

    Is the menu bar missing (the one containing File, View, Edit etc)? If it is, the following link shows how to restore it - https://support.mozilla.com/kb/Menu+bar+is+missing

  • ALV grid with editable fields

    Dear Colleagues,
    I develop an ALV grid with OO standard methods. Before the first display of the table I define the editable fields. It works fine.
    I have a problem : if the table is empty and I press the standard icons "Append a line" or "Insert a line", the new line don't have the defined editable characteristics.for fields. Is there a standard method which I have forgotten ?
    Thanks a lot and kind regards
    Peter

    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_delete_row.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_append_row.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy_row.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_insert_row.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_cut.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_undo.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
        vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
        APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    * Displaying the output in ALV Grid
        vs_layout_grid-no_rowmark = 'X'.
        vs_layout_grid-zebra      = 'X'.
        vs_layout_grid-cwidth_opt = 'X'.
        vs_layout_grid-edit       = 'X'.
        vs_layout_grid-ctab_fname = 'CT'.
        vs_layout_grid-stylefname = 'CELLTAB'.
        CALL METHOD v_grid->set_table_for_first_display
          EXPORTING
            i_save                        = 'X'
            is_layout                     = vs_layout_grid
            it_toolbar_excluding          = i_toolbar_excluding[]
          CHANGING
            it_outtab                     = itab[]
            it_fieldcatalog               = it_fieldcat[]
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc NE 0.
          MESSAGE 'ALV Grid display unsuccessful' TYPE 'I'.
          STOP.
        ENDIF.                             " IF sy-subrc NE 0
      ELSE.                                " IF w_custom_container...
    * Refresh the container if it already exists
        CALL METHOD v_grid->refresh_table_display
          EXCEPTIONS
            finished = 1
            OTHERS   = 2.
        IF sy-subrc NE 0.
          MESSAGE 'Refreshing the container is not successful' TYPE 'I'.
          STOP.
        ENDIF.                            

Maybe you are looking for

  • Need help in SQL query to get only distinct records

    Hi all. I am new to oracle SQL and i want to write a query to get only distinct values from 2 tables. for example i hade 2 tables table1(employee_id,employee_no,grade) and another table2 with same structure. for example data in table1 is Employeeid e

  • Problems on NW PI 7.1 after setting up a Windows Domain

    Hello Experts, we have had a SAP system running without a windows domain name. Everything works fine until we need to set up a windows domain because of the "full qualified domain name error". Now after setting up the domain we have problems to acces

  • Safari on My late mac mini 2012 plays shakey videos on youtube

    When i play back videos on youtube the is a problem with the video it shakes however the sound is not effected and it only happens on Safari, I have updated flash player and still I can not watch videos properly.

  • How could I do a gallery within a gallery?

    Basically I want a want a large content box with 6 smaller boxes beneath it. Clicking any of the smaller boxes will bring up a different gallery in the large content box. I think I want to use jquery sliders for each the gallery but i don't really kn

  • Phishing attempt that worked......

    Hi, I accidentaly gave the password of my macbook pro as well as my gmail account password. I received a email from a friend and I gave my passwords believing I had to, in order to get his document through google drive.... I was very stupid... . Imme