Help reqd. in Scrollable JTextArea

Simple JTextarea query.. how to create Scrollable JTextArea.
Thanks.

Thanks. I did it like this. When I am appending the text , Text area width is getting expanded but scroll bar is not coming. How to fix the width & height of a scroll bar & getting scroll bar if text is more. Also How to go for a new line in text area.
JTextArea textArea = new JTextArea(5,10);
JScrollPane scroll = new JScrollPane(textArea);
textArea.append("TEST j jnkejfemvlemf l mcelfmle ekmlemvl vkemv");
jPanel.add(textArea);
thanks in advance.

Similar Messages

  • Error in MIRO Help Reqd

    I have setup new instance. Created p.o & done MIGO things worked fine. In MIRO typically error is seen in tax code. I have assigned Tax procedure TAXGB to country IN. In Fin Acct in tax on sales & purchases defined new taxcode VX with country option IN. Still during MIRO its showing error Tax code VN & Country IN doesnot exist in procedure TAXGB. In error msg its M8 249 & origin is shown as check invoice document.
    Help reqd from SAP Gurus pls.
    Regards

    Check these links
    while doing MIRO, i am getting error:-Tax code V0 country IN does not exist
    Tax code Z4 country IN does not exist in procedure TAXINJ
    Tax code V0 country IN does not exist in procedure TAXINN
    Tax code V0 country IN does not exist in procedure TAXINN

  • Urgent Help Reqd: Delta Problem....!!!

    Hi Experts,
    Urgent help reqd regarding follwoing scenario:
    I am getting delta to ODS 1 (infosource : 2LIS_12_VCHDR) from R/3. Now this ODS1 gives delta to Cube1. I got one error record which fails when going to cube (due to master data check).And this record would be edited later.
    So I thought of re loading cube and using error handling to split request in PSA and load valid records in cube.Later when I have coorect info abt error, I would load erroneous record manually using PSA.
    I did following steps:
    1)Failed request is not in cube...(setting is PSA and then into target)....also it has been deleted from PSA.
    2)Remove data status from source ODS1.
    3)Change error handling in infopackage to valid " Valid records update, reporting possible".
    4)start loading of cube.
    But when I did this I got following message :
    <b> "Last delta update is not yet completed.Therefore, no new delta update is possible.You can start the request again if the last delta request is red or green in the monitor"</b>
    But both my requests in cube and ODS are Green...no request is in yellow...!!
    Now the problem is :
    1) I have lost ODS data mart status
    2)how to load valid records to cube, since errorneous record can be edited only after 3- 4 days.
    3)How not to affect delta load of tomorrow.
    Please guide and help me in this.
    Thanks in advance and rest assured I will award points to say thanks to SDNers..
    Regards,
    Sorabh
    Message was edited by: sorabh arora

    Hi Joseph,
    Thanks for replying....
    I apolgize and I have modified the message above..
    I just checked in cube...there is no failed request for today...and neither in PSA....Person who has handed this to me may have deleted this is PSA..and why req is not in failed state in cube...I am not sure..though setting is "PSA and then into data package".....
    So how to go frm here....
    Thanks
    Sorabh

  • Multiple scrollable JTextArea in a JTable

    Hi,
    I want to created a JPanel and added a Jtable (10 columns and 10 rows). So I've 100 JTextArea in a panel. But i don't know how to make all these textareas scrollable. Can anyone help me?
    thanks,
    Yigit

    Your message does sound rather confusing. In any case, this is how you add a scrollpane to a JTextArea, tweak it a bit and add it to a pane:
        listTextArea = new JTextArea();
        listTextArea.setFont(new Font("Verdana", Font.PLAIN, 14));
        listTextArea.setEditable(false);
        listTextArea.setLineWrap(true);
        listTextArea.setWrapStyleWord(true);
        JScrollPane listTextScrollPane = new JScrollPane(listTextArea);
        listTextScrollPane.setVerticalScrollBarPolicy(JScrollPane.
                                                      VERTICAL_SCROLLBAR_AS_NEEDED);
        listTextScrollPane.setHorizontalScrollBarPolicy(JScrollPane.
            HORIZONTAL_SCROLLBAR_NEVER);
        listTextScrollPane.setPreferredSize(new Dimension(860, 340));
        listPanel.add(listTextScrollPane);You can do a similar operation on a JTable. What I am trying to understand is if you would like to be able to add a scrollpane to each cell or something similar...

  • Help to access a JTextArea created in another method ?

    Hello, first I am a new to java although i am a very experienced PHP programmer ... i am having trouble figuring out why i cannot access the JTextArea created inside BuildContainer() in my program below from another method NewFile().
    I am sure its just a scope issue or something along those lines, can someone please help with this and also explain to me whay it does not work and why something elese if offered will ?
    Ive hit a roadblock, and its driving me nuts.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*; 
    public class JEditor implements ActionListener {
         public static void main (String args[])
              JEditor Obj = new JEditor ();
              Obj.BuildGui ();
         public void actionPerformed(ActionEvent e)
         public void BuildGui ()
              JFrame WindowFrame = new JFrame("JEditor");
              JMenuBar WindowMenuBar = BuildMenuBar ();
              BuildContainer(WindowFrame.getContentPane());
              WindowFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              WindowFrame.setJMenuBar(WindowMenuBar);
              WindowFrame.pack();
              WindowFrame.setVisible(true);
         public JMenuBar BuildMenuBar ()
              Action Action_MenuNew = new Action_NewFile();
              Action Action_MenuOpen = new Action_OpenFile();
              Action Action_MenuSave = new Action_SaveFile();
              Action Action_MenuExit = new Action_Exit();
              JMenuBar Obj = new JMenuBar ();
              JMenu MenuObj = new JMenu("File");
              JMenuItem MenuItemNew = new JMenuItem(Action_MenuNew);
              JMenuItem MenuItemOpen = new JMenuItem(Action_MenuOpen);
              JMenuItem MenuItemSave = new JMenuItem(Action_MenuSave);
              JMenuItem MenuItemExit = new JMenuItem(Action_MenuExit);          
              MenuItemNew.setText("New");
              MenuItemOpen.setText("Open");
              MenuItemSave.setText("Save");
              MenuItemExit.setText("Exit");     
              MenuItemNew.addActionListener(this);
              MenuItemOpen.addActionListener(this);
              MenuItemSave.addActionListener(this);
              MenuItemExit.addActionListener(this);
              MenuObj.add(MenuItemNew);
              MenuObj.add(MenuItemOpen);
              MenuObj.add(MenuItemSave);
              MenuObj.addSeparator();
              MenuObj.add(MenuItemExit);
              Obj.add(MenuObj);
              return Obj;
         public JToolBar BuildToolBar ()
              Action Action_ButtonNew = new Action_NewFile();
              Action Action_ButtonOpen = new Action_OpenFile();
              Action Action_ButtonSave = new Action_SaveFile();
              JToolBar Obj = new JToolBar ();
              JButton ButtonNew = new JButton (Action_ButtonNew);
              JButton ButtonOpen = new JButton (Action_ButtonOpen);
              JButton ButtonSave = new JButton (Action_ButtonSave);
              ButtonNew.setIcon(new ImageIcon("IconNew.png", "New"));
              ButtonOpen.setIcon(new ImageIcon("IconOpen.png", "Open"));
              ButtonSave.setIcon(new ImageIcon("IconSave.png", "Save"));
              ButtonNew.setToolTipText("New file");
              ButtonOpen.setToolTipText("Open file");
              ButtonSave.setToolTipText("Save file");
              ButtonNew.addActionListener(this);
              ButtonOpen.addActionListener(this);
              ButtonSave.addActionListener(this);
              Obj.add(ButtonNew);
              Obj.add(ButtonOpen);
              Obj.add(ButtonSave);
              return Obj;
         public void BuildContainer (Container Obj)
              Obj.setLayout(new GridBagLayout());
              GridBagConstraints C = new GridBagConstraints();
              JToolBar ToolBar = BuildToolBar ();
              JTextArea FormTextArea = new JTextArea(10, 50);
              FormTextArea.setLineWrap(true);
              FormTextArea.setWrapStyleWord(true);
              JScrollPane FormScrollPane = new JScrollPane(FormTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              C.gridx = 0;
              C.gridy = 0;
              Obj.add(ToolBar, C);
              C.gridx = 0;
              C.gridy = 1;
              Obj.add(FormScrollPane, C);
         public void NewFile ()
              // Problem is here ? Cannot access the textarea from here, not sure why ?
              FormTextArea.setText("test");
         public class Action_NewFile extends AbstractAction {
              public void actionPerformed(ActionEvent e)
                   NewFile ();
    };

    first I am a new to java You should learn the standard Java naming conventions. Basically variable names and method names should be mixed lower/upper case on each word:
    windowFrame -not WindowFrame
    buildMenuBar() - not BuildMenuBar()
    For class names you do upper case the the first character of each word.
    Your code is confusing to read since everything is upper cased and therefore looks like a reference to a class.

  • HELP !!! JTextArea in a JDialog !!!

    I have a JTextArea in a Dialog but there is no scrollbars !!!
    How can i create a scrollbar, please help !!!

    The scroll bar kicks in when required.
    L.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    package diatextscroll;
    import java.awt.*;
    import javax.swing.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class Dialog1 extends JDialog {
    private JPanel panel1 = new JPanel();
    private BorderLayout borderLayout1 = new BorderLayout();
    private JScrollPane jScrollPane1 = new JScrollPane();
    private JTextPane jTextPane1 = new JTextPane();
    public Dialog1(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
    jbInit();
    pack();
    setVisible(true);
    catch(Exception ex) {
    ex.printStackTrace();
    public Dialog1() {
    this(null, "", false);
    private void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    jTextPane1.setText("jTextPane1");
    getContentPane().add(panel1);
    panel1.add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTextPane1, null);
    public static void main(String[] args) {
    Dialog1 dlg = new Dialog1();

  • Help reqd on RG23D

    Hi abappers....
    My requirement is.....
    Opening Stocks at Plant(werks) level for RG23D balances to be captured line itemwise to generate 'A' Certificate Separtely....
    Im a beginner in ABAP and i dont know which tables,fields...i've to take and make a report as reqd.
    If anyone have solution or example of reports for this...pls post me your replies here on urgent basis.
    ******my email id:[email protected]
    thanks & regards.
    sankar

    Hi
    CSV means a text file, where the columns are separated by a character ";".
    The best way to change a list to CSV is to create an internal table in the ABAP, with the structure of the required CSV.
    You have to fill in this internal table.
    Because you are running the program in background, you can't download the file, the best would be to store the file on the server in a separated directory.
    1ST capture file from application server to internal table using open dataset and close data set.
    Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma separated format then download this internal table using the Function Module GUI_DOWNLOAD.
    EX-
    Coding -
    TYPE-POOLS: truxs.
    TYPES:
    BEGIN OF ty_Line,
    vbeln LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
    END OF ty_Line.
    TYPES: ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.
    DATA: itab TYPE ty_Lines.
    DATA: itab1 TYPE truxs_t_text_data.
    SELECT
    vbeln
    posnr
    UP TO 10 ROWS
    FROM vbap
    INTO TABLE itab.
    CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
    EXPORTING
    i_field_seperator = ';'
    TABLES
    i_tab_sap_data = itab
    CHANGING
    i_tab_converted_data = itab1
    EXCEPTIONS
    conversion_failed = 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 'GUI_DOWNLOAD'
    EXPORTING
    filename = 'C:\TEMP\test.txt'
    TABLES
    data_tab = itab1
    EXCEPTIONS
    OTHERS = 1.
    Thanks,
    Reward If Helpful.

  • Scrollable JTextArea

    I am having serious issues with a JTextArea and a JScrollPane. The code is posted below but I'll say what I am trying to do. I am creating a game and am creating a chat form. I have a JTextArea where all the chat will be displayed and then right below it a JTextField that accepts user input. The chat functions correctly, but doesn't display properly. There are two issues that I need addressed. One, the chat doesn't properly flow, what it does it shows 4 lines, then the rest disappears. Two, the scrollbar shows up, but does not scroll, it does not react to user input at all, the mouse wheel doesnt work, I can't click on the arrows, nor can I drag the scrollbar.
    I have does this successfully in several applications and I am either faced with a java bug, an inconvenience, and am just plain overlooking something stupid. Thanks for the help.
    Below is the code I use to setup my interface. mappanel is a custom control, it extends JPanel, rightpanel is another custom control, the postedchat is a JTextArea, the rest I believe is self explainatory.
    this.setLayout(null);
              Rectangle bounds = this.getContentPane().getBounds();
              mappanel = new MapPanel(this);
              mappanel.setBounds(0, 0, mappanel.getWidth(), mappanel.getHeight());
              this.add(mappanel);
              rightpanel = new RightPanel();
              rightpanel.setBounds(mappanel.getWidth() + 1, 0, rightpanel.getHeight(), rightpanel.getWidth());
              this.add(rightpanel);
              postedchat = new JTextArea();
              //postedchat.setSize(100, 50);
              //postedchat.setEditable(false);
              //postedchat.setBounds(0, 0, mappanel.getWidth(), (int)bounds.getHeight() - mappanel.getHeight() - 20);
              JScrollPane scrollarea = new JScrollPane(postedchat);
              //scrollarea.getViewport().add(postedchat);
              scrollarea.setBounds(0, mappanel.getHeight() + 1, mappanel.getWidth(), (int)bounds.getHeight() - mappanel.getHeight() - 20);
              scrollarea.setPreferredSize(new Dimension(mappanel.getWidth(), (int)bounds.getHeight() - mappanel.getHeight() - 20));
              this.add(scrollarea);
              //Chat field KeyListener
              final JTextField chat = new JTextField();
              chat.setBounds(0, (int)bounds.getHeight() - 20, mappanel.getWidth(), 20);
              class SendChat implements KeyListener
                   public void keyPressed(KeyEvent e)
                        if(e.getKeyCode() == KeyEvent.VK_ENTER)
                             String message = chat.getText();
                             server.SendChat(message);
                             chat.setText("");
                   public void keyTyped(KeyEvent e){}
                   public void keyReleased(KeyEvent e){}
              chat.addKeyListener(new SendChat());
              this.add(chat);
              this.repaint();Thank you for all the help.

    I do not want to use a layout manager as I wish to place them based on x, y coordinates.Most newbies want to do this because they don't understand the power of layout managers. Learning how to use layout managers will save you time in the long run and you will have a better more maintainable GUI.
    Unless there is another way to place the components EXACTLY where I want them.Its called using a layout manager. Rarely do you ever need to specify exact pixel locations of a component. You only want components to be line up in a straight line relative to other components so the GUI looks neat and tidy.
    Is the JScrollPane not working because of the lack of a LayoutManager? Sometimes it can be the problem. But you didn't post a SSCCE so we don't know for sure.
    Also, you should not be using a KeyListener on your text field. You should be using an ActionListener. The text field will invoke the ActionListener when enter is pressed on the text field.
    I suggest you read the Swing tutorial for proper usage of layout managers and other other Swing features.

  • Scrollable JTextArea problem. Tried the techniques of previous posts.

    Hi guys,
    I know this is a very common post on this forum. I have tried the solutions mentioned in previos posts, but somehow I am unable to make a JTextArea Scrollable.
    I have written the following code :
              TAlab1 = new JTextArea(temp);
              TAlab1.setBounds(50, 130, 530, 50);
              TAlab1.setBorder(BorderFactory.createEtchedBorder() );
              TAlab1.setLineWrap(true);
              TAlab1.setEditable(false);
              jsp = new JScrollPane(TAlab1);
              p.add(jsp); // where p is JPanelHere, if I add jsp, then the JTextArea is not visible. If I add TAlab1, then I get a JTextArea, but which is not scrollable.
    I would appreciate any of your assistance.
    Regards
    kbhatia

    Calling setBounds can get you in trouble. Hardcoding values is almost always a bad idea. Here's a short demo of adding a JTextArea to a JScrollPane;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ScrollTest extends JFrame{
        private String longString = "This is just a long string to be added over and over again to textarea\n";
        int times = 0;
        private JTextArea textArea;
        public ScrollTest() {
            buildGUI();
        private void buildGUI(){
            JPanel mainPanel = (JPanel) getContentPane();
            mainPanel.setLayout(new BorderLayout());
            JPanel centerPanel = buildCenterPanel();
            mainPanel.add(centerPanel, BorderLayout.CENTER);
            JPanel buttonPanel = buildButtonPanel();
            mainPanel.add(buttonPanel, BorderLayout.SOUTH);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            pack();
            setLocationRelativeTo(null);
            setVisible(true);
        private JPanel buildButtonPanel() {
            JPanel retPanel = new JPanel();
            JButton addButton  = new JButton("Add Text");
            addButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    addText();
            retPanel.add(addButton);
            return retPanel;
        private void addText() {
            textArea.append(times+ " "+longString);
            times +=1;
        private JPanel buildCenterPanel() {
            JPanel retPanel = new JPanel(new GridLayout(1,0, 5,5));
            textArea = new JTextArea(5,10);
            textArea.setWrapStyleWord(true);
            textArea.setLineWrap(true);
            textArea.setEditable(false);
            textArea.setEnabled(false);
            JScrollPane jsp = new JScrollPane(textArea);
            retPanel.add(jsp);
            return retPanel;
        public static void main(String[] args) {
            new ScrollTest();
    }Cheers
    DB

  • Help reqd to display the FORM without Print method.

    Hi all,
    I did one gate pass form and i want to view the form in my selection screen or output screen(just in monitor) as  a display by giving one Z-code.
    i.e, we can view the form thru Print preview...the same preview, i want to display after i give my parameter in the selection screen.
    For example.ZGPOUT if i enter as a t-code.
    it should ask my Gate Pass number in the Selection screen...if its right then my Form will come out to the display screen. (instead of going by Print method).,
    Pls post ur comment and reply me with examples,if possible.
    thanks & regards
    sankar.

    Hi Sankar,
    Its bit ambigious......but logic is very simple...........
    1. Create a Z.....report
    2. Inside this create your selection parameters
    3. Do your logic for the selection screen(use list box option or F4 help) to ask for the gate pass number.
    4. Call the required form. (For print preveiw assign 'X' to tdpreview of ITCPO)
    5. Finally assign your print program to the tcode which will finally do rest of the coding.
    Thanks,
    Mark

  • Urgent: ABAP Code help reqd

    Hi,
    Can anyone please me provide me ABAP code for the following case:
    Table1 – JHAGA
    Table2 – JHAGVZ
    Primary keys in JHAGA:
    Order Item Number [POS_NR]
    Billing Dataset [GRUPPABRNR]
    Sales Document Number [AVM_NR]
    This requirement is for an InfoSet. For each order ideally we can have multiple sales agent. Sales Agent is being pulled from JHAGVZ. For this InfoSet we are going to go with assumption that we wont have more then 10 sales agent for an order,
    Consider 10 extra fields in InfoSet SA1 – SA10 for 10 Sales Agent.
    I need code which to populate this sales agent field. If an order exists in JHAGA then for that order in JHAGVZ populate the SA1-SA10 field.
    JHAGA – Order#10
    JHAGVZ – Order#10 – SalesAgent11
                   SalesAgent12
                   SalesAgent13
    Then SA1 should have SalesAgent11, SA2 should have SalesAgent12 and SA3 should have SalesAgent13 and so on…     
    Thank you,
    sam

    HI ,
    Are these two field a part of the table INFOROBJECT?
    if they are, you can write a select statement like :
    select 0CUSTOMER 0SALESORG YLEG_ENTITY
           from INFOROBJECT
           into Y_CUST_LE
           where ( Yacc_SEQ <> ´ZROO´  and
                   0PRICE_LIST <> space).
    Hope this helps.
    If not, please explain problem clearly.

  • ID configuation help reqd...

    Hi,
    Proxy async to JDBC sync to   proxy async scenario
    i hav an OA_MI request for Proxy (outbound async) and an AA_MI request for proxy
    IA_MI Response for proxy AA_MI respons for proxy
    AS_MIRequest and response for proxy  for operation mapping
    IS_MI request and response for JDBC
    AS_MI request and response for JDBC
    AA_MI request for JDBC(sync send step in bpm)
    AA_MI response for JDBC(sync send step)
    two mappings one for request and other for response
    and one Operation mapping
    I have a BPM sceanario Recv(AA_MI requestproxy) > send synchronous(AS_MI request and response for JDBC)>send step(IA_MI Response for proxy)
    I know i need three recvr determinations and interface determinations..but could some one help me out with the interfaces in recvr determinations and interface determinations.. am jus confused since a synchronous Operation mapping

    For Proxy to BPM:
    Receiver Determination (Source Interface)---> Outbound Proxy Async Interface.....Receiver Service will be BPM
    Interface Determination:
    Source Interface ---> Outbound Proxy Async Interface
    Inbound Interface ---> Abstract Async Interface (of BPM)
    If there is any mapping program defined then include it here for Source_to_BPM
    No Sender/ Receiver CC & Agreement required.
    For BPM to JDBC:
    Receiver Determination (Source Interface) ---> Abstract Sync Interface (JDBC Req & Resp message types)...Receiver Service will be the JDBC
    Interface Determination:
    Source Interface ---> Abstract Sync Interface (JDBC Req & Resp message types)
    Inbound Interface ---> Inbound Sync Interface (JDBC Req & Resp message types)
    If there is any mapping program defined then include it here for BPM_to_JDBC
    Receiver CC and Receiver Agreement required.
    For BPM to Proxy:
    Receiver Determination (Source Interface)---> Abstract Async Interface ..... Receiver System will be the SAP system
    Interface Determination:
    Source Interface ---> Abstract Async Interface
    Inbound Interface ---> Inbound Async Interface...proxy interface
    If there is any mapping program defined then include it here for BPM_to_Proxy
    Receiver CC and Receiver Agreement required.
    Regards,
    Abhishek.

  • Help reqd for Selection Screen Input paramter

    Hi Friends,
    I've developed a noraml ALV grid report which have Date selection option as input selection parameter. In that , I want to declare last month date as defualt value to date-low range. Whenever the Tcode is entered, it should show the date ranges with my default values as date-low is last month date and date-high is current system date (this one I've given as sy-datlo).
    Please help me how to declare last month date to my low range field.
    thanks & regards
    sankar.

    Hi Suhas,
    i think so there is no need to specify the sign and options.
    SELECT-OPTIONS:so_dat for sy-datum.
    INITIALIZATION.
    so_dat-low = sy-datum.
    so_dat-high = sy-datum.
    append so_dat.
    START-OF-SELECTION.
    BREAK-POINT.
    it assigns BT by default.
    Sankar:Please provide your code

  • Sql query - help reqd

    Hi,
    I require help for sql query. The query will be like
    "SELECT * FROM XYZ WHERE TEXT = 'h*s' "
    and the results will be come like
    “his”
    “homes”
    “houses”
    “horses”,
    “horticulturalists”
    “herbaceous”.
    Thanks,
    Kapil

    Hello,
    SELECT   *
      FROM   XYZ
    WHERE   TEXT LIKE ('h%s');Regards
    Edited by: OrionNet on Feb 2, 2009 12:33 AM

  • Query on Decode --help reqd

    Hi
    I am executing a query:
    select vetno,category from vetno where vetno.category IN (select decode (REP_VET_CATG,NULL,'('A','B')','REP_VET_CATG') from dual);
    The REP_VET_CATG variable takes the value from the GUI.
    I want the functionality such that if it is NULL then the query should be
    select vetno,category from vetno where vetno.category IN ('A','B');
    else
    Take the values that is passed i.e the query should be like this
    select vetno,category from vetno where vetno.category = 'REP_VET_CATG';
    I tried the above query but it gives me a error missing right paranthesis.
    Can anyone help ......with this OR suggest a better alternative..

    Do you mean this?
    SQL> create table vetno
      2  as
      3  select 1 vetno, 'A' category from dual union all
      4  select 2, 'B' from dual union all
      5  select 3, 'C' from dual
      6  /
    Tabel is aangemaakt.
    SQL> var REP_VET_CATG varchar2(1)
    SQL> exec :REP_VET_CATG := null
    PL/SQL-procedure is geslaagd.
    SQL> select vetno
      2       , category
      3    from vetno
      4   where (   :REP_VET_CATG is null
      5         and vetno.category in ('A','B')
      6         )
      7      or (   :REP_VET_CATG is not null
      8         and vetno.category = :REP_VET_CATG
      9         )
    10  /
                                     VETNO C
                                         1 A
                                         2 B
    2 rijen zijn geselecteerd.
    SQL> exec :REP_VET_CATG := 'C'
    PL/SQL-procedure is geslaagd.
    SQL> select vetno
      2       , category
      3    from vetno
      4   where (   :REP_VET_CATG is null
      5         and vetno.category in ('A','B')
      6         )
      7      or (   :REP_VET_CATG is not null
      8         and vetno.category = :REP_VET_CATG
      9         )
    10  /
                                     VETNO C
                                         3 C
    1 rij is geselecteerd.Regards,
    Rob.

Maybe you are looking for