Problem in adding of tab in MIGO

hi all,
     I added one tab in MIGO at item details. i created one program and designed one screen. here i am calculating batch code based on screen fields . i need to update standard batch code field with my calculated batch code.  How to update field that is in different tab. Please suggest.
Thanx & Regards
Rami Reddy

You have to contact iTunes Store Support about this.
http://www.apple.com/support/itunes/contact/

Similar Messages

  • Problem in adding new tabs in master data screens for RE-FX in ECC 6.0

    Dear members,
    I am working on RE-FX in ECC 6.0. I need some advice on the foll matter:
    When displaying master data for Rental Object (Rental Space) (Tcode REBDRO) there are three tabs that are visible. They are General Data, Measurement and Area Shares. I would like the tab "Supplementary Texts" to also appear as the fourth tab. I have gone to the node Screen Sequence under the Dialog node under Usage View under Master Data in RE-FX.
    I have added this screen to the sequence and have saved it successfully. Now when i am trying to display the rental space (RS) it is still not showing the tab that I just added. When I am trying to remove one of the existing tabs, by going into the same screen sequence I am successful in doing that. I am also able to add some of the other tabs. However every time I am trying to add the tab "Supplementary texts", I am failing to display it in the master data.
    Request you to please help me as I am not an expert in RE-FX.
    Regards,
    Suvarghya Dutta

    Hi Survaghya,
    We are facing problem in adding tab to transaction RESCSU. We have followed all the steps mentioned by you , like
    1. Go to transaction BUPT .
    2. Select Application Object - transactuion BUS0.
    3.Selected Application object as RESU.
    4. And then went to all the following transactions.
        RESCSU0002     SU: Field Groups
        RESCSU0003     SU: Views
        RESCSU0004     SU: Sections
        RESCSU0005     SU: Screens
        RESCSU0006     SU: Screen Sequences.
    5. Created one z function group , having 2 FM for PBO and PAI.
    6. Also one subscreen having the field mapped to CI_INCLUDE - CI_VISCSU.
    But still we are not able to see the tab on the settlemet screen.
    We tried changing the screen sequence of existing tabs, we could change that, but after performing all the steps mentioned above we could not add new tab.
    Please suggest where are we committing a mistake.
    Thanks & Regards,
    Deepti

  • Userexit or BADI for adding additional tab in MIGO screen.

    Hi all ,
       Kindly tell me as to which exit or BADI is used to add additional tab in MIGO header.
    Regards

    Hi,
    Create a program with the screen type sub-screen in SE80 and design the layout for the custom fields.
    Declare the custom fields in a Z**TOP include.
    Under the PBO method declare the program name and screen number
    Under PAI method declare the field to u2018Xu2019.
    Under the line modify method declare a flag and set to u2018Xu2019 checking for material document number by which we can set the fields to be in display mode when we open MIGO for display of material document created after doing goods receipt.
    Under the POST_DOCUMENT method write the code for appending the value to Z table along with the values of the line item (In this case production order number, material, u2026u2026.). For these values to be available here in this method use the memory concept u201CExport to memory idu201D in the method LINE_MODIFY. 
    In order to do any validations to the custom fields, go to transaction SE80 and mention the program Name created and in PROCESS ON VALUE_REQUEST create a module and provide the validations required for those custom Fields.
    In order to make the fields to be in display mode during the display of material document, create a module under PBO and import the flag value and the production order number details in the method LINE_MODIFY and if that flag = u2018Xu2019, use  
    LOOP AT SCREEN.
    IF SCREEN-NAME = 'ZZGBAGS'.
    SCREEN-INPUT = '0'.
    MODIFY SCREEN.
    ENDIF.
    ENDLOOP.Retrieve the values from the Z table matching the key field (production order number) and pass the value of the custom field on to the screen.

  • Adding new tab in MIGO Tcode at item leveli

    HI all,
    My requirement is to create a new tab at item level in MIGO Tcode. In that tab I have to add some z-fields, here the point to be noted is these custom fields data needs to be saved into a Z-table along with the goods receipt number which is generated whenever we post the GR. So I searched for screen exits for this. I was not able to found this.
    But I was able to find out a BADI "MB_MIGO_BADI". Is this the right BADI, if so could you let me know in which method I could be able to get the saved GRN number for that posted document. How could I call my custom tab in this BADI.
    If there is any alternate method also, could you please let me know.
    Thanks and regards,
    Srinivas.
    Edited by: Vinod Kumar on Jul 7, 2011 10:30 PM

    Hi gvsastry,
    Thanks for your prompt response, I should save ztable data along with the GRN number which is generated when we post data.
    means if the GR posting fails the Z-table data should not be saved. So is that method which you said, will be triggred after the GR posting itself.
    Regards,
    Srinivas.

  • New Tab is replacing the Excise Invoice tab on MIGO Header

    Hi All,
      I have Added new tab in MIGO Header,it is working fine, if i am doing MIGO for Excisable PO , then Excise Details tab is not appearing In my MIGO header (New Tab is replacing the Excise Detils Tab) and at my item level Exise item tab is dispaying.
    I have Used BADI  :  MB_MIGO_BADI 
    At PBO_HEADER,
      data: gf_class_id type migo_class_id.
      gf_class_id = 'MIGO_BADI_IMPLEMENTATION_CIN'.
      E_CPROG = 'ZMIGO_VENDTAB'.
      E_DYNNR = '0001'.
      E_HEADING = 'Vendor Details'.
    Please help me.

    Hello
    Refer to below Code.
    METHOD IF_EX_MB_MIGO_BADI~PBO_HEADER.
           CHECK I_CLASS_ID = GF_CLASS_ID.
           IF MIGO_HTAB = 'GR'.
             IF G_NO_INPUT IS INITIAL.
               E_CPROG   = 'SAPLZMIGBADI'.
               E_DYNNR   = '9000'.                     "External fields: Input
               E_HEADING = 'EXTRA GR'(001).
             ELSE.
               E_CPROG   = 'SAPLZMIGBADI'.
               E_DYNNR   = '9000'.                     "External fields: Input
               E_HEADING = 'EXTRA GR'(001).
             ENDIF.
           ENDIF.
           IF MIGO_HTAB = 'GI'.
             IF G_NO_INPUT IS INITIAL.
               E_CPROG   = 'SAPLZGDRCV'.
               E_DYNNR   = '9000'.                     "External fields: Input
               E_HEADING = 'EXTRA GI'(002).
             ELSE.
               E_CPROG   = 'SAPLZGDRCV'.
               E_DYNNR   = '9000'.                     "External fields: Input
               E_HEADING = 'EXTRA GI'(002).
             ENDIF.
           ENDIF.
           IF MIGO_HTAB = 'GR'.
             CALL FUNCTION 'ZMIGO_BADI_PUT_HEADER'
               EXPORTING
                 IS_MIGO_BADI_HEADER_FIELDS = GS_EXDATA_HEADER.
           ENDIF.
           IF MIGO_HTAB = 'GI'.
             CALL FUNCTION 'ZMIGO_BADI_PUT_HEADER_GI'
               EXPORTING
                 IS_MIGO_BADI_HEADER_FIELDS = GS_EXDATA_HEADER.
           ENDIF.
    ENDMETHOD.
    Abhinav Singh

  • A new TAB in MIGO both at header as well at item level

    hey Folks ,
    My requirement is I want to add a new TAB in MIGO both at header as well at item level , I have made efforts with BADI *mb_migo_badi * and added the tab with a text box   .
    I want to save the text added in the text box  ,
    Please help how to procede ...!
    Regards
    Swapnil

    Hey Ashok ,
    I have already made the efforts with the same class .
    My problem is that i had to save the TEXT in the TEXT BOX with the OBJECT ID ,OBJECT NAME  I have used various function mobules as create text ,save text also .....!
    Have created  OBJECT ID  using SE75 since for MIGO transaction its not provided by SAP
    Please guide me for the same .
    Regards
    Swapnil

  • Additional Tab in MIGO Item details.

    Dear Experts,
                                 My client is procuring Fuel as a stock material. the delivery of fuel is being done into tanks for which Initial & final dip readings are to be recorded.
                                                              SO is  it possible to add an additional Tab in MIGO Item Level, with additional fields so that I can enter Initial & Final readings for a Fuel which is being procured as a stock material with other parameters like density, temperature, water content etc. "Does adding an Additional Tab & Fields lead to any implications in SAP? "
    Thanks & Regards
    Chandan H N

    I think the best solution for u is to work in batch management and classification (class and characteristic)
    so that u can input all the parameters like density, temperature, water content etc as per ur requirement.
    i think just creating tab in migo only data entry u will be able to do and u will have to do the development.
    but batch mgt and classification is std and u will be able to track the things
    hope this helps

  • Profit Segment in Account Assignment Tab of MIGO?

    Hi,
    Why is profit segment showing up in the account assignment tab when I am trying to post the goods receipt for a purchase order through MIGO? The material is a drop ship.
    I am not maintaining profit center fields in the material master.
    Please help me with this question.
    Thanks,
    Ketan

    Hello Ketan,
    I am also facing more or less the same issue where I am getting the following:
    When I try to post goods receipt for a direct shipment, I receive the error: Inconsistency between a document field and profitability segment number.
    I noticed that in the account assignment tab of MIGO,  there is a field/section for Profit segment and I belive this is causing the problem. We have never maintained profit center so I am wondering where it came from.
    Did you solve your issue?
    Regards,
    Puja

  • Excise Invoice tab In MIGO transaction code

    Hello
    Could any body suggest, In Excise Invoice tab In MIGO transaction code I am getting "06  No Excise Entry" no otehr fields are coming.? All options like
    01     Capture & Post Excise Invoice
    02     Refer & Post Excise Invoice
    03     Only Capture Excise Invoice
    04     Only Refer Excise Invoice
    05     Only Part1
    Should come. Infact in my SAND Box client it is o.k but with same setting Golden Client it is not coming.?
    Thanks & Regards
    Sudhansu

    Hi,
    These options are coming from Excise Group settings.
    Go to : SPRO-Logistics General-Tax on Goods movements-India-Basic settings-Maintain Excise Groups-in 'MIGO Settings' tab, select the check boxes, accordingly you will get the options in Excise Tab of MIGO screen.
    Hope this will resolve your issue.
    Regards,
    Gopi Chand

  • Excise Tab in MIGO for import PO

    Dear all
    When doing MIGO for Import PO excise tab is not appearing for the material
    I have maintained all the data in J1ID for the material and plant
    already we use to capture EI for the same material and plant but this time this is creating issues
    We have posted an inoice of  planned delivery costs but no excise tab in MIGO
    What might be the reason

    >
    cnranjith wrote:
    > Dear all
    >
    > When doing MIGO for Import PO excise tab is not appearing for the material
    >
    > I have maintained all the data in J1ID for the material and plant
    >
    > already we use to capture EI for the same material and plant but this time this is creating issues
    >
    > We have posted an inoice of  planned delivery costs but no excise tab in MIGO
    >
    > What might be the reason
    First you have to post the Customs MIRO in case of import purchase...then go for MIGO...you will find excise tab will follow....
    Regards,
    Indranil

  • Excise Invoice tab in MIGO

    Hi
    In the headre screen of MIGO transaction only Generel, Vendoe and puychasing grp tabs are displayed. The excise invoice tab is not seeing. It is not displaying.I want it to be displayed.pls tell me
    regards
    B shar

    Hi,
    If you want the excise tab in MIGO transaction you need to do the customization in
    SPROLog genTax on goods mvtIndiaBasic settings--Maintain Excise groups.
    Here for your excise groups at the bottom you have MIGO settings you have to select the checkboxes as per that then save the settings.
    Then in MIGO transaction you will find the excise tab both at header & item level.
    Also you need to maintain all the excise details in J1ID table.
    rgds
    Chidanand

  • Excise Invoice Tab in MIGO for non-codified materials

    Hi!
    While doing MIGO against PO, for non-codified materials ( No material code, Account assignment in P.O - F), Excise Invoice Tab Pop-Up is coming in MIGO. There is no excise related master data maintained in J1ID.
    What could be the reason? Can any body suggest in this reg..
    I am using ECC 6.0
    Thanks & Regards,
    Gopi Chand

    Hi,
    These options are coming from Excise Group settings.
    Go to : SPRO-Logistics General-Tax on Goods movements-India-Basic settings-Maintain Excise Groups-in 'MIGO Settings' tab, select the check boxes, accordingly you will get the options in Excise Tab of MIGO screen.
    Hope this will resolve your issue.
    Regards,
    Gopi Chand

  • Not showing Excise invoice tab in Migo while Display

    Dear SAPient's,
    While displaying material document in MIGO. No Excise Invoice tab is showing altough it is there while creating GRN.
    please Do needful.
    warm Regards,
    Bijay jha

    Hi,
    As you want to see "Excise "Tab in MIGO while displaying material document in MIGO t.code, 1st check do you have authorization to view Excise document, If yes, You can view the excise details in MIGO t.code.
    2ndly check, During goods receipt , did the excise duties are captured in MIGO t.code.If yes , you can view all details if you have authorization.
    Also check did that material which is excisable have  CIN master data in J1ID t.code.
    NOTE: To capture excise duties  in t.code:MIGO, you need to do following settings:(check did you have such in your system,,,)
    Select check boxes of "EI capture" & "Post EI in MIGO" in MIGO Settings segment in Maintaining Excise Group setting in following path:
    SPRO --- >Logistics general - > tax on Goods Movements- >India --- >Basic setting --- >Maintain Excise Groups
    Also set entry of 101 Movement Type for capturing Excise Duties in following path:
    SPRO --- >Logistics general - > tax on Goods Movements- >India - >Business Transactions->Specify Which Movement Types Involve Excise Invoices
    Regards,
    Biju K

  • Problem with adding Sun JSF RI v1.2 as a new library in JDeveloper 10.1.3.1

    Hi,
    I have a problem with adding a latest JSF 1.2 RI from Sun (https://javaserverfaces.dev.java.net/files/documents/1866/44998/jsf-1_2_03.zip) to JDeveloper as a new library.
    I created a new User library and added into it jsf-impl.jar and jsf-api.jar from JSF 1.2 RI.
    Then I try to create two new JSP Tag libraries based from .tld files.
    When a .tld file is placed in "TLD File:" field there is no information below about Library Version and Required JSP Version. If I check "Execute Tags in JSP Visual Editor" and click "Customize" button - list of tags in "Customize Tag Library" window is empty.
    I have errors when I try to use JSF Tags from this new library in JSP page like :
    "Can't create tag instance: f:view (class: null). Make sure, that the tag class or a library contained this class is available in this application"
    (free translation to English)
    Is this possible to add JSF RI v1.2 as another library in Jdeveloper 10.1.3.1 ?
    thanks for help
    koli

    Hi,
    This solution is not exactly for Jdeveloper 10.1.3.x I think.
    - "Create a JSF system library." section, point 2. - there is not possible to add library in folder other than User I see, so I added it in User folder.
    - "Register the JSF JSP tag libraries." section, point 5. - in JD 10.1.3 there is no dialog box, I checked checkbox "Show Tag Library in Palette". A new library was added to User folder but there is no new libraries in component Palette.
    Even as I use "Edit tag libraries .." from Component Palette context menu and add manually new tag libraries to selected, there is no libraries in Component Palette after it.
    I feel so problem is with different .tld files format, not with adding libraries method.
    Sun RI tld file (from version 1.2_03) fragment:
    <taglib xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
    version="2.1">
    <!-- ========== Tag Library Description Elements ========================= -->
    <description>
    The core JavaServer Faces custom actions that are independent of
    any particular RenderKit.
    </description>
    <tlib-version>1.2</tlib-version>
    <short-name>f</short-name>
    <uri>http://java.sun.com/jsf/core</uri>
    tld included in JD:
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <!-- ========== Tag Library Description Elements ========================= -->
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>f</short-name>
    <uri>http://java.sun.com/jsf/core</uri>
    <description>
    The core JavaServer Faces custom actions that are independent of
    any particular RenderKit.
    </description>
    Did JDeveloper 10.1.3.x maintain with taglib version 1.2 ?
    Regards
    koli

  • JTable sorting - problem when adding elements (complete code inside)

    I�m writing this email with reference to a recent posting here but this time with the code example. (I apologize for the duplicated posting � this time it will be with the code)
    Problem: when adding more elements to the JTable (sorted) the exception: ArrayIndexOutOfBoundsException is thrown.
    Example: If the elements in the table are 10 and then the user requests for 8 � the table will produce the correct result. However, if the user will ask for 11 items (>10) the exception will be thrown.
    The program: The program below (compiles and running). A JTable is constructed with 3 items, when you click the button - the return result should be 4 items - this will generate the error, WHY?
    I would highly appreciate your thoughts why this is happening and most importantly � how to fix it.
    Thanks a lot
    3 files:
    (1) TableSorterDemo
    (2) Traveler
    (3)TableSorter
    //TableSorterDemo:
    package sorter;
    import javax.swing.DefaultListModel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * TableSorterDemo is like TableDemo, except that it
    * inserts a custom model -- a sorter -- between the table
    * and its data model.  It also has column tool tips.
    public class TableSorterDemo implements ActionListener
         private JPanel superPanel;
         private JButton clickMe = new JButton("click me to get diff data");
         private boolean DEBUG = false;
         private DefaultListModel defaultListModel;
         private JTable table;
        public TableSorterDemo()
             superPanel = new JPanel(new BorderLayout());
             defaultListModel = new DefaultListModel();
             init1();
            TableSorter sorter = new TableSorter(new MyTableModel(defaultListModel)); //ADDED THIS     
            table = new JTable(sorter);             //NEW
            sorter.setTableHeader(table.getTableHeader()); //ADDED THIS
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            //Set up tool tips for column headers.
            table.getTableHeader().setToolTipText(
                    "Click to specify sorting; Control-Click to specify secondary sorting");
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            superPanel.add("Center", scrollPane);
            superPanel.add("South",clickMe);
            clickMe.addActionListener(this);              
        public JPanel getPanel()
             return superPanel;
        public void init1()
             //in real life this will be done from the db
             Traveler a = new Traveler();
             Traveler b = new Traveler();
             Traveler c = new Traveler();
             a.setFirstName("Elvis");
             a.setLastName("Presley");
             a.setSprot("Ping Pong");
             a.setNumYears(3);
             a.setVegetarian(true);
             b.setFirstName("Elton");
             b.setLastName("John");
             b.setSprot("Soccer");
             b.setNumYears(2);
             b.setVegetarian(true);
             c.setFirstName("shaquille");
             c.setLastName("oneil");
             c.setSprot("Golf");
             c.setNumYears(22);
             c.setVegetarian(true);
             defaultListModel.addElement(a);
             defaultListModel.addElement(b);
             defaultListModel.addElement(c);
        public void init2()
             //in real life this will be done from the db
             Traveler d = new Traveler();
             Traveler e = new Traveler();
             Traveler f = new Traveler();
             Traveler g = new Traveler();
             d.setFirstName("John");
             d.setLastName("Smith");
             d.setSprot("Tennis");
             d.setNumYears(32);
             d.setVegetarian(true);
             e.setFirstName("Ron");
             e.setLastName("Cohen");
             e.setSprot("Baseball");
             e.setNumYears(12);
             e.setVegetarian(true);
             f.setFirstName("Donald");
             f.setLastName("Mac Novice");
             f.setSprot("Vallyball");
             f.setNumYears(1);
             f.setVegetarian(true);
             g.setFirstName("Eithan");
             g.setLastName("Superstar");
             g.setSprot("Vallyball");
             g.setNumYears(21);
             g.setVegetarian(true);
             defaultListModel.addElement(d);
             defaultListModel.addElement(e);
             defaultListModel.addElement(f);
             defaultListModel.addElement(g);            
        class MyTableModel extends AbstractTableModel
             private DefaultListModel myModel;
             public MyTableModel(DefaultListModel m)
                  myModel=m;
            private String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            public int getColumnCount()
                return columnNames.length;
            public int getRowCount()
                return myModel.size();
            public String getColumnName(int column)
                 return getNames()[column];             
             public String[] getNames()
                  String[] names = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
                  return names;
            public Object getValueAt(int row, int col)
                 return distributeObjectsInTable(row, col, (Traveler) myModel.elementAt(row));
            public Object distributeObjectsInTable(int row, int col, Traveler tr)
               switch(col)
                         case 0:
                              return tr.getFirstName();
                         case 1:
                           return tr.getLastName();
                      case 2:
                           return tr.getSprot();
                      case 3:
                           return new Integer(tr.getNumYears());
                      case 4:
                           return new Boolean (tr.isVegetarian());
                     default:
                         return "Error";
            public Class getColumnClass(int c)
                return getValueAt(0, c).getClass();
        private static void createAndShowGUI()
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("TableSorterDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            TableSorterDemo newContentPane = new TableSorterDemo();
            newContentPane.getPanel().setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane.getPanel());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable()                   
                public void run()
                    createAndShowGUI();
         public void actionPerformed(ActionEvent ae)
              if (ae.getSource()==clickMe)
                   defaultListModel.removeAllElements();
                   init2(); //if the size of the model was less than 2 items - the result will be ok.
                              //in other words, if you commens the last 2 rows of this method (addElement(f) & g)
                             // the result will be fine.
                   table.updateUI();          
    }//(2) Traveler
    package sorter;
    public class Traveler
         private String firstName;
         private String lastName;
         private String sprot;
         private int numYears;
         private boolean vegetarian;
         public String getFirstName()
              return firstName;
         public String getLastName()
              return lastName;
         public int getNumYears()
              return numYears;
         public String getSprot()
              return sprot;
         public boolean isVegetarian()
              return vegetarian;
         public void setFirstName(String firstName)
              this.firstName = firstName;
         public void setLastName(String lastName)
              this.lastName = lastName;
         public void setNumYears(int numYears)
              this.numYears = numYears;
         public void setSprot(String sprot)
              this.sprot = sprot;
         public void setVegetarian(boolean vegetarian)
              this.vegetarian = vegetarian;
    }//(3)TableSorter
    package sorter;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    public class TableSorter extends AbstractTableModel {
        protected TableModel tableModel;
        public static final int DESCENDING = -1;
        public static final int NOT_SORTED = 0;
        public static final int ASCENDING = 1;
        private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
        public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return ((Comparable) o1).compareTo(o2);
        public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return o1.toString().compareTo(o2.toString());
        private Row[] viewToModel;
        private int[] modelToView;
        private JTableHeader tableHeader;
        private MouseListener mouseListener;
        private TableModelListener tableModelListener;
        private Map columnComparators = new HashMap();
        private List sortingColumns = new ArrayList();
        public TableSorter() {
            this.mouseListener = new MouseHandler();
            this.tableModelListener = new TableModelHandler();
        public TableSorter(TableModel tableModel) {
            this();
            setTableModel(tableModel);
        public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
            this();
            setTableHeader(tableHeader);
            setTableModel(tableModel);
        private void clearSortingState() {
            viewToModel = null;
            modelToView = null;
        public TableModel getTableModel() {
            return tableModel;
        public void setTableModel(TableModel tableModel) {
            if (this.tableModel != null) {
                this.tableModel.removeTableModelListener(tableModelListener);
            this.tableModel = tableModel;
            if (this.tableModel != null) {
                this.tableModel.addTableModelListener(tableModelListener);
            clearSortingState();
            fireTableStructureChanged();
        public JTableHeader getTableHeader() {
            return tableHeader;
        public void setTableHeader(JTableHeader tableHeader) {
            if (this.tableHeader != null) {
                this.tableHeader.removeMouseListener(mouseListener);
                TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                if (defaultRenderer instanceof SortableHeaderRenderer) {
                    this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
            this.tableHeader = tableHeader;
            if (this.tableHeader != null) {
                this.tableHeader.addMouseListener(mouseListener);
                this.tableHeader.setDefaultRenderer(
                        new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
        public boolean isSorting() {
            return sortingColumns.size() != 0;
        private Directive getDirective(int column) {
            for (int i = 0; i < sortingColumns.size(); i++) {
                Directive directive = (Directive)sortingColumns.get(i);
                if (directive.column == column) {
                    return directive;
            return EMPTY_DIRECTIVE;
        public int getSortingStatus(int column) {
            return getDirective(column).direction;
        private void sortingStatusChanged() {
            clearSortingState();
            fireTableDataChanged();
            if (tableHeader != null) {
                tableHeader.repaint();
        public void setSortingStatus(int column, int status) {
            Directive directive = getDirective(column);
            if (directive != EMPTY_DIRECTIVE) {
                sortingColumns.remove(directive);
            if (status != NOT_SORTED) {
                sortingColumns.add(new Directive(column, status));
            sortingStatusChanged();
        protected Icon getHeaderRendererIcon(int column, int size) {
            Directive directive = getDirective(column);
            if (directive == EMPTY_DIRECTIVE) {
                return null;
            return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
        private void cancelSorting() {
            sortingColumns.clear();
            sortingStatusChanged();
        public void setColumnComparator(Class type, Comparator comparator) {
            if (comparator == null) {
                columnComparators.remove(type);
            } else {
                columnComparators.put(type, comparator);
        protected Comparator getComparator(int column) {
            Class columnType = tableModel.getColumnClass(column);
            Comparator comparator = (Comparator) columnComparators.get(columnType);
            if (comparator != null) {
                return comparator;
            if (Comparable.class.isAssignableFrom(columnType)) {
                return COMPARABLE_COMAPRATOR;
            return LEXICAL_COMPARATOR;
        private Row[] getViewToModel() {
            if (viewToModel == null) {
                int tableModelRowCount = tableModel.getRowCount();
                viewToModel = new Row[tableModelRowCount];
                for (int row = 0; row < tableModelRowCount; row++) {
                    viewToModel[row] = new Row(row);
                if (isSorting()) {
                    Arrays.sort(viewToModel);
            return viewToModel;
        public int modelIndex(int viewIndex)
            return getViewToModel()[viewIndex].modelIndex;
        private int[] getModelToView()
            if (modelToView == null) {
                int n = getViewToModel().length;
                modelToView = new int[n];
                for (int i = 0; i < n; i++) {
                    modelToView[modelIndex(i)] = i;
            return modelToView;
        // TableModel interface methods
        public int getRowCount() {
            return (tableModel == null) ? 0 : tableModel.getRowCount();
        public int getColumnCount() {
            return (tableModel == null) ? 0 : tableModel.getColumnCount();
        public String getColumnName(int column) {
            return tableModel.getColumnName(column);
        public Class getColumnClass(int column) {
            return tableModel.getColumnClass(column);
        public boolean isCellEditable(int row, int column) {
            return tableModel.isCellEditable(modelIndex(row), column);
        public Object getValueAt(int row, int column) {
            return tableModel.getValueAt(modelIndex(row), column);
        public void setValueAt(Object aValue, int row, int column) {
            tableModel.setValueAt(aValue, modelIndex(row), column);
        // Helper classes
        private class Row implements Comparable {
            private int modelIndex;
            public Row(int index) {
                this.modelIndex = index;
            public int compareTo(Object o) {
                int row1 = modelIndex;
                int row2 = ((Row) o).modelIndex;
                for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
                    Directive directive = (Directive) it.next();
                    int column = directive.column;
                    Object o1 = tableModel.getValueAt(row1, column);
                    Object o2 = tableModel.getValueAt(row2, column);
                    int comparison = 0;
                    // Define null less than everything, except null.
                    if (o1 == null && o2 == null) {
                        comparison = 0;
                    } else if (o1 == null) {
                        comparison = -1;
                    } else if (o2 == null) {
                        comparison = 1;
                    } else {
                        comparison = getComparator(column).compare(o1, o2);
                    if (comparison != 0) {
                        return directive.direction == DESCENDING ? -comparison : comparison;
                return 0;
        private class TableModelHandler implements TableModelListener {
            public void tableChanged(TableModelEvent e) {
                // If we're not sorting by anything, just pass the event along.            
                if (!isSorting()) {
                    clearSortingState();
                    fireTableChanged(e);
                    return;
                // If the table structure has changed, cancel the sorting; the            
                // sorting columns may have been either moved or deleted from            
                // the model.
                if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                    cancelSorting();
                    fireTableChanged(e);
                    return;
                // We can map a cell event through to the view without widening            
                // when the following conditions apply:
                // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                // d) a reverse lookup will not trigger a sort (modelToView != null)
                // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                // The last check, for (modelToView != null) is to see if modelToView
                // is already allocated. If we don't do this check; sorting can become
                // a performance bottleneck for applications where cells 
                // change rapidly in different parts of the table. If cells
                // change alternately in the sorting column and then outside of            
                // it this class can end up re-sorting on alternate cell updates -
                // which can be a performance problem for large tables. The last
                // clause avoids this problem.
                int column = e.getColumn();
                if (e.getFirstRow() == e.getLastRow()
                        && column != TableModelEvent.ALL_COLUMNS
                        && getSortingStatus(column) == NOT_SORTED
                        && modelToView != null) {
                    int viewIndex = getModelToView()[e.getFirstRow()];
                    fireTableChanged(new TableModelEvent(TableSorter.this,
                                                         viewIndex, viewIndex,
                                                         column, e.getType()));
                    return;
                // Something has happened to the data that may have invalidated the row order.
                clearSortingState();
                fireTableDataChanged();
                return;
        private class MouseHandler extends MouseAdapter {
            public void mouseClicked(MouseEvent e) {
                JTableHeader h = (JTableHeader) e.getSource();
                TableColumnModel columnModel = h.getColumnModel();
                int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                int column = columnModel.getColumn(viewColumn).getModelIndex();
                if (column != -1) {
                    int status = getSortingStatus(column);
                    if (!e.isControlDown()) {
                        cancelSorting();
                    // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                    // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                    status = status + (e.isShiftDown() ? -1 : 1);
                    status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                    setSortingStatus(column, status);
        private static class Arrow implements Icon {
            private boolean descending;
            private int size;
            private int priority;
            public Arrow(boolean descending, int size, int priority) {
                this.descending = descending;
                this.size = size;
                this.priority = priority;
            public void paintIcon(Component c, Graphics g, int x, int y) {
                Color color = c == null ? Color.GRAY : c.getBackground();            
                // In a compound sort, make each succesive triangle 20%
                // smaller than the previous one.
                int dx = (int)(size/2*Math.pow(0.8, priority));
                int dy = descending ? dx : -dx;
                // Align icon (roughly) with font baseline.
                y = y + 5*size/6 + (descending ? -dy : 0);
                int shift = descending ? 1 : -1;
                g.translate(x, y);
                // Right diagonal.
                g.setColor(color.darker());
                g.drawLine(dx / 2, dy, 0, 0);
                g.drawLine(dx / 2, dy + shift, 0, shift);
                // Left diagonal.
                g.setColor(color.brighter());
                g.drawLine(dx / 2, dy, dx, 0);
                g.drawLine(dx / 2, dy + shift, dx, shift);
                // Horizontal line.
                if (descending) {
                    g.setColor(color.darker().darker());
                } else {
                    g.setColor(color.brighter().brighter());
                g.drawLine(dx, 0, 0, 0);
                g.setColor(color);
                g.translate(-x, -y);
            public int getIconWidth() {
                return size;
            public int getIconHeight() {
                return size;
        private class SortableHeaderRenderer implements TableCellRenderer {
            private TableCellRenderer tableCellRenderer;
            public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
                this.tableCellRenderer = tableCellRenderer;
            public Component getTableCellRendererComponent(JTable table,
                                                           Object value,
                                                           boolean isSelected,
                                                           boolean hasFocus,
                                                           int row,
                                                           int column) {
                Component c = tableCellRenderer.getTableCellRendererComponent(table,
                        value, isSelected, hasFocus, row, column);
                if (c instanceof JLabel) {
                    JLabel l = (JLabel) c;
                    l.setHorizontalTextPosition(JLabel.LEFT);
                    int modelColumn = table.convertColumnIndexToModel(column);
                    l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                return c;
        private static class Directive {
            private int column;
            private int direction;
            public Directive(int column, int direction) {
                this.column = column;
                this.direction = direction;
    }

    The table listens to the TableModel for changes. Changing the table by adding/removing
    rows or columns has no affect on its table model. If you make changes to the table model
    the table will be notified by its TableModelListener and change its view. So tell
    MyTableModel about the change of data:
    public class TableSorterDemo implements ActionListener
        MyTableModel tableModel;
        public TableSorterDemo()
            defaultListModel = new DefaultListModel();
            init1();
            tableModel = new MyTableModel(defaultListModel);
            TableSorter sorter = new TableSorter(tableModel);
        public void actionPerformed(ActionEvent ae)
            if (ae.getSource()==clickMe)
                defaultListModel.removeAllElements();
                init2();
                tableModel.fireTableStructureChanged();
    }

Maybe you are looking for