Create a JTable based on an ArrayList containing instances of a class.

I have a class, IncomeBudgetItem, instances of which are contained in an ArrayList. I would like to create a JTable, based on this ArrayList. One variable is a string, while others are type double. Not all variables are to appear in the JTable.
The internal logic of my program is already working. And my GUI is largely constructed. I'm just not sure how to make them talk to each other. The actually creation of the JTable is my biggest problem right now.

import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
public class TableDemo extends JPanel {
     private boolean DEBUG = false;
     public TableDemo() {
          super(new GridLayout(1, 0));
          ArrayList<MyObject> list = new ArrayList<MyObject>();
          list.add(new MyObject("Kathy", "Smith", "Snowboarding", new Integer(5),
                    new Boolean(false)));
          list.add(new MyObject("John", "Doe", "Rowing", new Integer(3),
                    new Boolean(true)));
          list.add(new MyObject("Sue", "Black", "Knitting", new Integer(2),
                    new Boolean(false)));
          list.add(new MyObject("Jane", "White", "Speed reading",
                    new Integer(20), new Boolean(true)));
          JTable table = new JTable(new MyTableModel(list));
          table.setPreferredScrollableViewportSize(new Dimension(500, 70));
          table.setFillsViewportHeight(true);
          // Create the scroll pane and add the table to it.
          JScrollPane scrollPane = new JScrollPane(table);
          // Add the scroll pane to this panel.
          add(scrollPane);
     class MyObject {
          String firstName;
          String lastName;
          String sport;
          int years;
          boolean isVeg;
          MyObject(String firstName, String lastName, String sport, int years,
                    boolean isVeg) {
               this.firstName = firstName;
               this.lastName = lastName;
               this.sport = sport;
               this.years = years;
               this.isVeg = isVeg;
     class MyTableModel extends AbstractTableModel {
          private String[] columnNames = { "First Name", "Last Name", "Sport",
                    "# of Years", "Vegetarian" };
          ArrayList<MyObject> list = null;
          MyTableModel(ArrayList<MyObject> list) {
               this.list = list;
          public int getColumnCount() {
               return columnNames.length;
          public int getRowCount() {
               return list.size();
          public String getColumnName(int col) {
               return columnNames[col];
          public Object getValueAt(int row, int col) {
               MyObject object = list.get(row);
               switch (col) {
               case 0:
                    return object.firstName;
               case 1:
                    return object.lastName;
               case 2:
                    return object.sport;
               case 3:
                    return object.years;
               case 4:
                    return object.isVeg;
               default:
                    return "unknown";
          public Class getColumnClass(int c) {
               return getValueAt(0, c).getClass();
      * Create the GUI and show it. For thread safety, this method should be
      * invoked from the event-dispatching thread.
     private static void createAndShowGUI() {
          // Create and set up the window.
          JFrame frame = new JFrame("TableDemo");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          // Create and set up the content pane.
          TableDemo newContentPane = new TableDemo();
          newContentPane.setOpaque(true); // content panes must be opaque
          frame.setContentPane(newContentPane);
          // 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();
}

Similar Messages

  • Creating a Set  containing instances of another Class, which type?

    Hi All,
    I'm stuck trying to create a set which contains instances of another Class.
    When I created my instance method, it takes an argument which is the instance of another Class.
    It errors as I've used the Class as the type rather than String> or Integer.
    Can someone point my in the right direction?
    WebPageData wpd1 = new WebPageData("this is a sentence for a test", "www.test.com");
    WebPageData wpd2 = new WebPageData("this sentence is shorter", "www.short.com");
    WebPageData wpd3 = new WebPageData("this is very short", "www.very.com");
    Finder f1 = new Finder();
    f1.addsite(wpd1);
    f1.addsite(wpd2);
    f1.addsite(wpd3);
    f1.searchFor("a sentence test");
    Edited by: geedoubleu on Mar 16, 2008 9:03 AM

    The error message is "Semantic error: line 5. Message addsite( WebPageData ) not understood by class'Finder'"
    * Adds the argument of WebPageData instances to to a collection scannedSites.
    public void addSite(WebPageData theWebPage)
    this.scannedSites.add(theWebPage);
    }

  • Create new JTable based on selection of previous table

    Hello All,
    I want to create a sort of selection table. I have a fairly large JTable that is row selectable. I want the user to be able to select some rows, and then create a smaller table just displaying the selected rows.
    The current problem I am having (I say current b/c I'm sure more will follow) results from users rearranging the columns.
    Example) When columns are arranged as: A B C. Then the user rearranges to B A C. The getColumns() method returns the columns in the right order (B A C), but the getData() method returns the data in the old arrangement. So the data now does not match up to the column names.
    Here are the two methods I mention above (note: This class extends from JTable, so the "super" calls call back to JTable):
    * Retrieves data from table.
    public Vector getData() {
      Vector data = ((DefaultTableModel)super.getModel()).getDataVector();
      return data;
    * Retrieves the column names
    public Vector getColumns() {
      Vector fieldNames = new Vector();
      Enumeration e = super.getTableHeader().getColumnModel().getColumns();
      while(e.hasMoreElements()) {
        String name = (String)((TableColumn)e.nextElement()).getHeaderValue();
        fieldNames.add(name);
      return fieldNames;
    }I hope I made my problem clear. Thanks for any/all suggestions!

    Ah! A vector of vectors is returned from the getData call.
    I assumed is was a vector as follows:
    A -> __data for A__
    B -> __data for B__
    C -> __data for C__
    But no, its:
    Row1 -> __A B C__
    Row2 -> __A B C__
    Row3 -> __A B C__
    etc...
    So after trying to code, I realized what I was doing. I was rearranging rows! Not columns! Why would JTable set up its rows in this fashion? Wouldn't it be more efficient to have the primary vector be the order of the columns? It seems that would make things much easier. Well, that's my little rant after finally realizing that my code wasn't broken, it was doing exactly what I told it to do!

  • Create a view - All Service Requests that contain a Completed Review Activity

    In the Service Manager 2012 console, is it possible to create a view that displays Service Requests, with the view criteria being something like as follows:
    Service Request status is In Progress
    Service Request contains a Review Activity where the Review Activity status is In Progress
    My intent is to provide a way for Service Desk Operators to be able to identify requests that are ready for implementation.
    From what I'm seeing in the console, this sort of view is not possible as it appears that any view criteria must be derived from the view's target class.

    Nothing like a bit of thread necromancy in the morning.
    It turns out the solution to this question was quite straight forward (once you know where to look...)
    The trick is creating a view based on one of the Service Request combination classes rather than the basic class itself, and then rephrasing my requirement after realising that what I was really after was a view containing Requests that have an In Progress
    Manual Activity.
    So...open the console, go to Work Items, right click on
    Service Request Fulfillment and select Create View
    On the General tab, give your view a name and select a Management in which it will be stored.
    On the Criteria tab, click Browse to select a specific object class.  Change the
    Frequently used basic classes filter to Combination classes then enter 'Service Request' in the filter field.
    Pick the Service Request and Activity class.
    Now when configuring the criteria, you'll notice a little arrow next to the
    Service Request class. Click on this arrow to expand the node, and select the
    Contains Activity class.
    Under the Available properties box, enter 'Status' in the search field. In my environment, I got two Status fields. Each corresponds to a specific Activity class. Select both of them and click
    Add.
    One of the Criteria will look like 'Contains Activity[Activity]Status'. Keep this one and delete the other from the Criteria box. Change the value to 'Completed'
    While we're at it, select the Service Request class and add a criteria for the Service Request Status = 'In Progress'.
    Click on the Display tab and select whatever fields you want to display in this view.  Click
    OK to save this view.
    Now go to the Administration workspace and select the
    Management Packs node. Export your management pack that contains your view and open the management pack in a text file viewer. Notepad++ works for me...
    First search for the string that you used to name your view. It will be found towards the bottom of the MP in a DisplayString element in the LanguagePacks XML element. This element will have an ElementID.
    Select the ElementID and search the entire file for this string. You want the instance that resides within a Presentation | Views | View element. From this point, scroll down until you get to a Criteria element. Within the Criteria element you will find
    the two Expressions that were entered via the GUI. One of the Expressions corresponds to the Service Request.Status=In Progress criteria, the other corresponds to the Activity.Status=In Progress criteria. We will be changing the Activity criteria so that it
    explicitly refers to a Manual Activity.
    Identify the Expression that has the Property containing the string 'System.WorkItemContainsActivity'. We will be changing the TypeConstraint attribute of this criteria.
    In this line, Replace the string 'System.WorkItem.Activity' with 'System.WorkItem.Activity.ManualActivity'
    Save this file and import the management pack into SCSM

  • Creating an Array based on values in an ArrayList

    How can I create an Array object which its values need to be obtained by iterating through an ArrayList and getting them one by one.
    In Detail:
    - I have an ArrayList of a StudentInfo object
    - Each StudentInfo contains an 'age' attribute.
    - I want to iterate through the ArrayList, retrieve each StudentInfo object, get
    the value of its age attribute and add it to the Array.
    Something like this:
    Integer[ ] ageNumbers;
    StudentInfo myStudentInfo= new StudentInfo ();
    for (Iterator it = myStudentInfo.iterator (); it.hasNext (); ) {
    myStudentInfo = (StudentInfo)it.next();
    myStudentInfo.getAge(); // this is where I�m stock, not sure how to add this
    value to my ageNumbers array.
    Thanks very much for the help!

    But which is the ArrayList containing your StudentInfo ?
    StudentInfo contain information about only one student ?
    In this case
    ArrayList allstudents = retrieve all students....
    Integer[] ageNumber = new Integer(allstudent.size());
    for(int i=0; i< allstudents.size(); i++) {
      StudentInfo student = (StudentInfo)allstudents.get(i);
      ageNumber[i] = student.getAge();
    }

  • How to update Jtable based on itemStateChanged in JComboBox?

    My bad... I originally posted this topic in the Java Programming forum before I found this forum. My apologies.
    Anyway, can someone help me out pls? I need to be able to update my JTable based on the selected item in the combobox. Unfortunately, my JTable doesn't update when I choose another item in the combo box. What am I doing wrong? I've read about TableModels but I'm not quite sure how to use it.
    my code:
    my_constructor()
    JComboBox cbdisease;
    cbdisease = new JComboBox();
    cbdisease.setEditable(false);
    cbdisease.setBounds(30,20,270,25);
    add(cbdisease);
    cbdisease.addActionListener(this);
    cbdisease.addItem("View All");
    //aside from "View All" that was previously added to the combo box
    //get the values from the database to fill the comboBox
    showDiseases();
    cbdisease.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent e)
    System.out.println(cbdisease.getSelectedItem());
    displayRules();
    }// end constructor
    method: showDiseases
    connect to DB and get D_Description (column in database)
    display D_Description in combo box
    public void showDiseases()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    rs = statement.executeQuery("SELECT DISTINCT D_Description FROM disease");
    //place D_Description in combo box
    while(rs.next())
    strDesc = rs.getString("D_Description");
    cbdisease.addItem(strDesc);
    conn.close();
    statement.close();
    } catch (SQLException sqle) {
    sqle.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    }//end catch
    }//end showDiseases()
    method: displayRules
    connect to DB and get the rules depending item selected in the combo box
    display the rules in a table
    public void displayRules()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    if(cbdisease.getSelectedItem().equals("View All"))
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease ORDER BY D_DiseaseCode, D_QuestionCode");
    else //query depends on the item selected in combo box other than "View All"
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease WHERE" + " D_Description = '" +cbdisease.getSelectedItem()+ "' ORDER BY D_DiseaseCode, D_QuestionCode");
    // Convert the result set into an array of Objects
    Object[][] rows = getObjects(rs);
    // These are the column headings displayed in the JTable
    String[] headings = { "Disease Code", "Description", "Question Code", "Question", "Action", "# of Arrows", "Arrow"};
    // Initialize a JTable with the rows of objects and column headings
    rulestable = new JTable(rows, headings);
    // Add the table to a JScrollPane to make it display nicely
    rulesScroll = new JScrollPane(rulestable);
    // Add the scroll pane to the container
    add(rulesScroll);
    rulesScroll.setBounds(30,80,720,380);
    conn.close();
    statement.close();
    } catch (SQLException sqle) {
    //sqle.printStackTrace();
    System.out.println(sqle.getSQLState());
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    }//end displayRules()
    method: getObjects
    public Object[][] getObjects(ResultSet rs) throws SQLException
    // Find out how many columns are in the result set
    ResultSetMetaData metaData = rs.getMetaData();
    final int colCount = metaData.getColumnCount();
    ArrayList rows = new ArrayList();
    Object[] row = null;
    while (rs.next()) {
    // for each row in the result set, put every column into a temporary Object array
    row = new Object[colCount];
    for (int a = 0; a < colCount; a++)
    row[a] = rs.getObject(a+1);
    // add the temporary Object array to the array list
    rows.add(row);
    // convert the array list to objects
    return (Object[][])rows.toArray(new Object[0][0]);
    }//end getObjects()

    Just pass the new data to a new TableModel object's
    constructor and then u can use this new table model in
    ur JTable constructor. that woud automatically update
    the table data.
    Cheers!
    Asimsir Asim, do you mean inserting
    DefaultTableModel rulesmodel = new DefaultTableModel(rows, headings);
    to my code?
    public void displayRules()
    Connection conn = null;
    ResultSet rs = null;
    Statement statement = null;
    try {
    // Connect to DB
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    conn = DriverManager.getConnection("jdbc:mysql:///dbused",
    "root", "");
    // create a statement, execute query
    statement = conn.createStatement();
    if(cbdisease.getSelectedItem().equals("View All"))
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease ORDER BY D_DiseaseCode, D_QuestionCode");
    else //query depends on the item selected in combo box other than "View All"
    rs = statement.executeQuery("SELECT D_DiseaseCode, D_Description, D_QuestionCode, D_Question, D_Action, D_NumArrow, D_Arrow FROM Disease WHERE" + " D_Description = '" +cbdisease.getSelectedItem()+ "' ORDER BY D_DiseaseCode, D_QuestionCode");
    // Convert the result set into an array of Objects
    Object[][] rows = getObjects(rs);
    // These are the column headings displayed in the JTable
    String[] headings = { "Disease Code", "Description", "Question Code", "Question", "Action", "# of Arrows", "Arrow"};
    // Initialize a JTable with the rows of objects and column headings
    rulestable = new JTable(rows, headings);
    // Add the table to a JScrollPane to make it display nicely
    rulesScroll = new JScrollPane(rulestable);
    // Add the scroll pane to the container
    add(rulesScroll);
    rulesScroll.setBounds(30,80,720,380);
    conn.close();
    statement.close();
    DefaultTableModel rulesmodel = new DefaultTableModel(rows, headings); //like this?
    rulestable.setModel(rulesmodel);     
    } catch (SQLException sqle) {
    //sqle.printStackTrace();
    System.out.println(sqle.getSQLState());
    } catch(Exception e) {
    System.err.println("Exception: " + e.getMessage());
    }//end displayRules()

  • How do I create a JTable with some empty cells in it?

    I have a three column JTable. The first column is a String showing description. The second column contains numbers (double) and the third column also contains numbers. In some cases not all cells in a row should contain data. So for instance, I could have row one showing only description (a String in the first column), and then row two showing description (a String in the first column) and a number (a double in the second column) in columns one and two respectively. My problem is that, the data gets copied from the cells with data to the cells which are supposed to be empty. So, how do I create a JTable with some empty cells in it.

    I have tried empty strings for those values, but it did not work. My table puts objects in an arraylist called reconciliation. The arraylist takes different objects with the same super class. The code below explains. Are you suggesting I pass null to my constructor?
    JTable table = new JTable(new ReconTableModel());The method below is from the table model
    protected  List<Reconciliation> reconciliation = new ArrayList<Reconciliation>();
    protected void fillModel(){
          reconciliation.add(new CashBook("Cash Book Report"," "," "));
          reconciliation.add(new CheckingBankAccount("Checking Bank Account"," "," "));
          reconciliation.add(new BankBalance("Bank Balance As Per Bank Statement",500," "));
          reconciliation.add(new PaymentVouchers("Payment Voucher Receipt",300," "));
          reconciliation.add(new DepositVoucher("Deposit Voucher Receipt",1000," "));
          reconciliation.add(new ReconciledBalance("Reconcilied Bank Balance",1200," "));
          reconciliation.add(new BalanceAt("Bank Balance At",800," "));
          reconciliation.add(new Difference("Difference",400," "));
          Collections.sort( reconciliation, new Comparator<Reconciliation>(){
          public int compare( Reconciliation a, Reconciliation b) {
            return a.getTransactionName().compareTo( b.getTransactionName());
      }

  • How to create a Service based on complex query

    Hi,
    I'm using JDev 11.1.2.2.0 for developing fusion based application based on EJB3.0 and JPA. I search on net and got a link for sample application as shown below:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/jdev/obe11jdev/ps1/ejb/ejb.html#t2s1
    But above application is based on "Entities based on Tables" but my requirement to build a service based on query which contains multiple tables which means I want to create a generic one...
    please let me know what I need to change or please provide any link for docs.

    Hi Desmukh,
    I want to create a wsdl for complex queries based on ADF fusion applicaiton using EJB3.0 and JPA...!
    the link which you provided 'entity with tables' which is restricting for my requirement but I want similar implementation for complex queries :(

  • How to create a condition based on a select that retrieve dynamically a LOV

    Hi all, I need to create a condition based on a select that retrieve dynamically a LOV.
    So, the condition have to be:
    inventory_item_id NOT IN (SELECT inventory_item_id FROM apps.mtl_system_items_kfv WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV')
    I need to create a LOV based on this select without making any join with the folder which contains the field inventory_item_id, because otherwise I have the contradiction:
    and o124757.INVENTORY_ITEM_ID = o118741.INVENTORY_ITEM_ID -- join between the main custom folder (o118741) and the LOV custom folder (o124757)
    and o118741.INVENTORY_ITEM_ID NOT IN (o124757.INVENTORY_ITEM_ID) -- condition
    These two condition together don't show any data, obviously....This means also, that I can't use a calculated field, because if I want to see this field, I have to create a join, another time, with the main custom folder.
    I tried to create a LOV on the Administrator, but when I create the condition I have to check manually the values....and if in the future this LOV will increase I need every time to re-check all the values.....instead I need that the inventory_item_id have to be NOT IN dinamically in the list of values retrieved by the select.
    Anybody has inplemented something similar ??
    Thanks in advance
    Alex

    Hi alex,
    SELECT incidents.INVENTORY_ITEM_ID,
    pcodes.PROBLEM_NAME
    FROM apps.cs_incidents_all_b incidents,apps.jtf_rs_problem_codes_v pcodes
    WHERE incidents.category_id IN (SELECT category_id
    FROM mtl_categories_kfv
    WHERE concatenated_segments = 'IPTV')
    AND incidents.PROBLEM_CODE = pcodes.PROBLEM_CODE
    where incidents.INVENTORY_ITEM_ID NOT IN SELECT inventory_item_id
    FROM apps.mtl_system_items_kfv
    WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
    You want to add this condition to the first query it holds good for this scenerio.All the items which are NOT IN will be retrieved.Here you are selecting other than "General_faults_iptv"
    But again your trying to select in the second query where you want "General_faults_iptv"
    SELECT inventory_item_id
    FROM apps.mtl_system_items_kfv
    WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
    If you carefully go through what your doing,you will understand.In the above explantion ,there will be no records generated.First query your saying NOT IN and again your saying for the same IN,how will records retrieve its meaningless.
    I dont know what you want to get from second query.I would suggest you to do is dont use the second query and just use the first query and you will get.Here is the query and this will give you result.
    SELECT incidents.INVENTORY_ITEM_ID,
    pcodes.PROBLEM_NAME
    FROM apps.cs_incidents_all_b incidents,apps.jtf_rs_problem_codes_v pcodes
    WHERE incidents.category_id IN (SELECT category_id
    FROM mtl_categories_kfv
    WHERE concatenated_segments = 'IPTV')
    AND incidents.PROBLEM_CODE = pcodes.PROBLEM_CODE
    AND incidents.INVENTORY_ITEM_ID NOT IN SELECT inventory_item_id
    FROM apps.mtl_system_items_kfv
    WHERE concatenated_segments = 'GENERAL_FAULTS_IPTV'
    Regards,
    Kranthi.

  • Creating a LOV based in a Web Service

    Hey guys...
    I need to create a Lov based in a Web Service Result, but in always getting the same error:
    LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Queries that I'm trying:
    Original Query:
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS'
    Other Query that I tried:
    select imgLocation, imgName from (
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS')
    And I tried creating a view, but I dont know where I have to put this.. Maybe in another process?
    create view as
    select imgLocation, imgName from (
    select extractValue(value(t),'/*/imgLocation','xmlns="http://oracle.ovs.api/types/"') "imgLocation"
    , extractValue(value(t),'/*/imgName','xmlns="http://oracle.ovs.api/types/"') "imgName"
    from wwv_flow_collections c,
    table(xmlsequence(extract(xmltype.createxml(c.clob001),'//getAllTemplateResourcesResponseElement/result','xmlns="http://oracle.ovs.api/types/"'))) t
    where c.collection_name = 'P1_GETALLTEMPLATERESOURCES2_RESULTS')
    Thanks

    Fox,
    I'd start by adding column aliases D and R to the query and see if that helps.
    Greg

  • Need to create a transformation based on Update Rules Logic

    Hi,
    I have an existing complex Update Rule. I need to manually create a Transformation based on this Update Rule logic. The Start Routine of the Update Rule comprises of:
    1) All data declarations in the Global Area
    2) The local coding area consists of various select statements from various r/3 tables used later for mapping. It also calculates and stores values in the Data Package final internal table for few infoobjects that are not present in the Source object but and are used to populated data in the target.
    3) then we have the various one to one individual Infoobject mappings/constants and many individual infoobject routines that pick result from the comm_structure
    I am not very clear as to where each of the above coding logic should be put in the transformation coding area...... I can see four main coding areas in the transformation....global area, 2nd Global Area, Method Start_Routine and Method Inverse_Start_Routine........... I think the global data declarations(point 1 above) should be put in the Global declaration area of the start routine. The local area of the update rule logic (point 2 above) that contains select statements should be put in 2nd Global part or should it be put in Method Start_routine????? Point 3 above for individual filed mappings will be done through Rule groups. Also can anyone let me know what is the methos inverse_start_routine used for?????
    Thanks.

    Hi,
    Point 1 you mentioned should be put under2nd Global declaration part of start routine.
    Point 2 should be put under Method Start_routine.
    Point 3 as you only mentioned can be done by individual field rule mappings.
    Method inverse_start_routine
          This subroutine needs to be implemented only for direct access
          (for better performance) and for the Report/Report Interface
          (drill through)
    Not very clear though about Inverse routine. But definetly not being used for the case you mentioned.
    Hope it helps.

  • How to create dynamic context based on a structure defined in the program?

    Hi Experts,
             I need to create a dynamic context based on a structure wa_struc which i have define programatically.
    When I pass wa_struc to structure_name parameter of create_nodeinfo_from_struc, i get a runtime error:
    "Parameter STRUCTURE_NAME contains an invalid value wa_struc."
    How to create dynamic context based on a structure defined in the program?
    I have written the code like this:
    TYPES: BEGIN OF t_type,
                v_carrid TYPE sflight-carrid,
                v_connid TYPE sflight-connid,
             END OF t_type.
      Data:  i_struc type table of t_type,
             wa_struc type t_type.
      data: dyn_node   type ref to if_wd_context_node.
      data: rootnode_info   type ref to if_wd_context_node_info.
      rootnode_info = wd_context->get_node_info( ).
      clear i_struc. refresh i_struc.
      select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
      parent_info = rootnode_info
      node_name = 'dynflight'
      structure_name = 'wa_struc'
      is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( name = 'dynflight' ).
    dyn_node->bind_table( i_struc ).
    Thanks
    Gopal
    Message was edited by: gopalkrishna baliga

    Hi Michelle,
              First of all Special thanks for your informative answers to my other forum questions. I really appreciate your help.
    Coming back to this question I am still waiting for an answer. Please help. Note that my structure is not in a dictionary.
    I am trying to create a new node. That is
    CONTEXT
    - DYNFLIGHT
    CARRID
    CONNID
    As you see above I am trying to create 'DYNFLIGHT' along with the 2 attributes which are inside this node. The structure of the node that is, no.of attributes may vary based on some condition. Thats why I am trying to create a node dynamically.
    Also I cannot define the structure in the ABAP dictionary because it changes based on condition
    I have updated my code like the following and I am getting error:
    TYPES: BEGIN OF t_type,
    CARRID TYPE sflight-carrid,
    CONNID TYPE sflight-connid,
    END OF t_type.
    Data: i_struc type table of t_type,
    dyn_node type ref to if_wd_context_node,
    rootnode_info type ref to if_wd_context_node_info,
    i_node_att type wdr_context_attr_info_map,
    wa_node_att type line of wdr_context_attr_info_map.
    wa_node_att-name = 'CARRID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CARRID'.
    insert wa_node_att into table i_node_att.
    wa_node_att-name = 'CONNID'.
    wa_node_att-TYPE_NAME = 'SFLIGHT-CONNID'.
    insert wa_node_att into table i_node_att.
    clear i_struc. refresh i_struc.
    select carrid connid into corresponding fields of table i_struc from sflight where carrid = 'AA'.
    rootnode_info = wd_context->get_node_info( ).
    rootnode_info->add_new_child_node( name = 'DYNFLIGHT'
    attributes = i_node_att
    is_multiple = abap_true ).
    dyn_node = wd_context->get_child_node( 'DYNFLIGHT' ).
    dyn_node->bind_table( i_struc ).
    l_ref_interfacecontroller->set_data( dyn_node ).
    But now I am getting the following error :
    The following error text was processed in the system PET : Line types of an internal table and a work area not compatible.
    The error occurred on the application server FMSAP995_PET_02 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    Method: IF_WD_CONTEXT_NODE~GET_STATIC_ATTRIBUTES_TABLE of program CL_WDR_CONTEXT_NODE_VAL=======CP
    Method: GET_REF_TO_TABLE of program CL_SALV_WD_DATA_TABLE=========CP
    Method: EXECUTE of program CL_SALV_WD_SERVICE_MANAGER====CP
    Method: APPLY_SERVICES of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: REFRESH of program CL_SALV_BS_RESULT_DATA_TABLE==CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE_DATA of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~MAP_FROM_SOURCE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMP_TABLE_DATA~UPDATE of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_VIEW~MODIFY of program CL_SALV_WD_C_TABLE_V_TABLE====CP
    Method: IF_SALV_WD_COMPONENT~VIEW_MODIFY of program CL_SALV_WD_A_COMPONENT========CP
    -Gopal
    Message was edited by: gopalkrishna baliga

  • Can I create a report based on Non-Oracle template?

    Hi:
    I have a Microsoft Word document that contains the entire layout of a report I need to create with Oracle Report 6i. I know that I can create a report based on a template, but as I understand it, I am limited to using Oracle Reports templates. Does Reports support using foreign templates? Thanks for any word in this manner.
    Thomas Morgan
    :)

    oracle reports does not support using ms word documents as templates. there is a product in the oracle applications stack, XML publisher, that allows you to inject data into a word template.
    thanks,
    ph.

  • Create a program, based on a report painter query issue continues

    Hi!
    I would like to create a program, which contains the same data, what I can get from a report, which is made by report painter in transaction GRR2. The given report is for checking the service orders.
    This report has a key (order number) and additional columns, like material cost, personal cost, external service cost, money income, etc...
    I found the COSP table, which can be very useful. Unfortunately COSP table contains only the costart (KSTAR) and I don't know, which costarts can be attached to the material costs, which costarts to the services, which costarts belong to the money income, etc...
    Could you please tell me, where can I find this assignment?
    Thank you
    Tamá

    Solved, here:
    Create a program, based on a report painter query

  • Create a formula based on UserResponse()

    Am trying to create a var based on Count(Payperiod) for overall report however whenever I include the formula at row level the value reverts to the individual row.  How can context be overriden? e.g. Formula is  Sum(HrsWorked)/Count(Payperiod)
    Where Count(Payperiod) is based on a range of dates selected from UserResponse() for a Beginning and Ending Payperiod.
    Report contains record for each employee and If Count(Payperiod) = 3 but that employee may have only HrsWorked recorded for one of the Payperiods
    I want calculation to use HrsWorked for each employee but I need to use the number of payperiods based on the UserResponse()s not on number of Payperiods recorded for employee.

    Hi
    try this syntax
    Sum(HrsWorked)/(Count(Payperiod) In Report)
    Regards,
    Stratos

Maybe you are looking for

  • Adobe Premiere Pro 2.0 & Adobe Encore 1.0?

    Hi there,<br /><br />Can some kind soul please point me to a resource or explain exactly what Encore v1.0 has to offer over & above Premiere Pro 2.0 and/or Premiere Elements 2.0?<br /><br />I have just built a new PC and not wanting to install anythi

  • Why can't I get AirPlay mirroring to work?

    When I double tap the home button and slide to the right, I can turn on AirPlay but it does not mirror to the tv.  The software is updated on my ipad2 and on apple tv.  My apps do AirPlay but the mirroring does not.

  • Urgent: Not all records extracted to ODS

    Hi, Not all of the records I am trying to load get updated to ODS. Ex: Doc#     Item#     Created On     Debit/Credit 1000     1     02012007     540 1000     2     02012007     540 1000     1     02022007     -540 1000     2     02022007     -540 Th

  • Firefox 3.6.3 truncates pages saving as PDF

    Same problem as posted by Kurt Blickenstaff Firefox user in April of 2010 - Safari 5.0.2 does NOT have problem when printing same Web pages Starting from "Printer Friendly" Web page, selecting sequence: Print, Save as PDF, a multi-page doc is truncat

  • Imac Intel Core Duo

    Can I install arch without problems in the new apple iMac with Intel core duo processor? Has anyone tried that? That machines look really really nice!! Regards