Generic Comparator problem

Hi!
In our code we use Comparator, but can not make it work with generics.
The only way is to insert cast in some places, but that destroy the point in using generics in the first place.
Basically we have a superclass Foo and child classes FooA, FooB, FooC etc. (FooX extends Foo)
In Foo there is a method that needs to compare two FooX objects (they are always both of the same type).
So Foo declares an abstract method getComparator() and then calls compare() from it.
The current code is like this :
public abstract class Foo {
    public abstract Comparator<? extends Foo> getComparator();
    private int doAndCompare(Foo newFoo) {
        if (0 == this.getComparator().compare(this, newFoo)) {
         // some code ...
// each FooX is like this
public class FooA extends Foo {
    static Comparator<FooA> myComparator = new Comparator<FooA>() {
        public int compare(FooA one, FooA two) {
            // the computation is specific for each FooX
            return xxx; // compute and return some int value
    public Comparator<FooA> getComparator() {
        return  myComparator;
}This code has a compile error in the if statement:
The method compare(capture-of ? extends Foo, capture-of ? extends Foo) in the type Comparator<capture-of ? extends Foo> is not applicable for the arguments (Foo, Foo)
I could use "super" instead of "extends" in the getComparator() definition, but the each FooX would have an error, which are solvable only by casting.
Is there a cast-less solution ?

This might not be the post that will answer your question (since I honestly do not completely get your question), but might provide some (to) creative insights.
A weird construct that will work without casting (but probably not very useful):
public static void main(String[] args) {
     FooX x1 = new FooX();
     FooX x2 = new FooX();
     // requires a parameter of type FooX
     x1.doAndCompare(x2);
     FooY y1 = new FooY();
     FooY y2 = new FooY();
     // requires a parameter of type FooY
     y1.doAndCompare(y2);
     Foo f1 = new FooY();
     Foo f2 = new FooY();
     f1.doAndCompare(y2); // requires a parameter of type Foo, so no actual benifit here? Will work though
     f1.doAndCompare(x2); // Will throw a ClassCastException, so not very usable
static abstract class Foo<T extends Foo<?>> implements Comparable<T> {
     public void doAndCompare(T foo) {
          if (0 == this.compareTo(foo)) {
               // do your magic
static class FooX extends Foo<FooX> {
     public int compareTo(FooX o) {
          // TODO Auto-generated method stub
          return 0;
static class FooY extends Foo<FooY> {
     public int compareTo(FooY o) {
          // TODO Auto-generated method stub
          return 0;
}An example that works with casting and that will work:
public static void main(String[] args) {
     FooX x1 = new FooX();
     FooX x2 = new FooX();
     // requires a parameter of type Foo, FooX.compareTo(FooX) will be invoked
     x1.doAndCompare(x2);
     FooY y1 = new FooY();
     FooY y2 = new FooY();
     // requires a parameter of type Foo, FooY.compareTo(FooY) will be invoked
     y1.doAndCompare(y2);
     // requires a parameter of type Foo
     y1.doAndCompare(x2); // will work
static abstract class Foo implements Comparable<Foo> {
     public void doAndCompare(Foo foo) {
          if (0 == this.compareTo(foo)) {
               // do your magic
static class FooX extends Foo {
     public int compareTo(Foo foo) {
          if (foo instanceof FooX) {
               return this.compareTo((FooX) foo);
          } else {
               return 1; // return what's apropriate of not equal
     public int compareTo(FooX fooX) {
          return 0;
static class FooY extends Foo {
     public int compareTo(Foo foo) {
          if (foo instanceof FooY) {
               return this.compareTo((FooY) foo);
          } else {
               return 1; // return what's apropriate of not equal
     public int compareTo(FooY fooY) {
          return 0;
}I couldn't help noticing that in your original post you very specifically used 'if comparision == 0'. That looks a lot like Foo.equals() to me. Isn't that just what you want?

Similar Messages

  • Generic Comparer Implementation

    Hi, I am trying to implement a generic comparer, as you can see (from the code below), this is probably the most raw / bad form of an implementation. I want it to work for all types, used if conditions for each data type, then realized that I am heading
    in the wrong direction. There must be an efficient way of writing it.
    I was trying to see if I can look at how Comparer<T> was implemented which derives from IComparer and IComparer<T>. But the code is not visible. Perhaps using reflection, might be possible. But I want to understand the idea behind a good comparer
    solution. Any help is much appreciated
    Thanks
    public class MyGenericComparer<T>
    public int Compare(T x, T y)
    if (typeof(T) == typeof(String))
    return ((string)(object)x).CompareTo((string)(object)y);
    if (typeof(T) == typeof(int))
    return ((int)(object)x).CompareTo((int)(object)y);
    return -999;

    In case you are asking what the good of an IComparer<T> is, this is the answer.
    IComparer<T> is provided in order to let developers use any comparison algorithms they prefer when instances of their classes or types are about to being compared. For example in an array of Product type, the default comparison for Product instances
    is compare based on reference, because they are object (reference-types).
    But, many scenarios exist that you might not want your objects are compared based on their reference. Suppose you want to sort your array of products based on their Weight, Price, Title, StockDate or whatever rule you might want.
    IComparer<T> is for such occasions. You can implement this interface in a class and give an instance of it to Array.Sort(). Then the array uses your custom comparer to sort your objects. 
    class Product
    public string Title;
    public float Price;
    public int Code;
    public bool InStock;
    public Product(string title, float price, int code, bool inStock)
    Title = title;
    Price = price;
    Code = code;
    InStock = inStock;
    class ProductPriceComparer: System.Collections.IComparer, System.Collections.Generic.IComparer<Product>
    // unchanged sections omitted
    public int Compare(Product x, Product y)
    if ((x == null) && (y == null))
    return 0; // null is equal to null
    if (x == null)
    return -1; // null is lower than anything
    if (y == null)
    return 1; // anything is greater than null
    int result;
    if (x.Price > y.Price)
    result = 1;
    else if (x.Price < y.Price)
    result = -1;
    else
    result = 0;
    return result;
    Product[] products = new Product[]
    new Product("HTC Desire S", 590.0f, 10025, true),
    new Product("Sony Ericsson Xperia Neo", 590.0f, 10032, true),
    new Product("Nokia X7", 570.0f, 10021, true),
    new Product("Motorola Atrix", 830.0f, 10034, false),
    new Product("LG Optimus One P500", 270.0f, 10035, true),
    new Product("Samsung I9100 Galaxy", 800.0f, 10029, true),
    new Product("Apple iPhone 4", 900.0f, 10024, false),
    new Product("Asus Eee Pad Transformer TF101", 750.0f, 10028, true),
    new Product("Archos 101 Internet Tablet", 450.0f, 10030, true)
    Product p;
    Console.WriteLine("\nSort by price…");
    Array.Sort(products, new ProductPriceComparer());
    for (int i = 0; i < products.Length; i++)
    p = products[i];
    Console.WriteLine("{0}: {1} ({2}$)", i + 1, p.Title, p.Price);
    You can implement as many comparer as you want.

  • Comparable problem with eclipse

    I want to use "Comparable" in eclipse, but always has a problem with a steatment that " The type Comparable is not generic; it cannot be parameterized with arguments <Node>".
    program is here:
    public class Node implements Comparable<Node>
         public int value;
         public boolean LeftchildSent; //used for checking if leftchild sent the value to the node at last round
         public boolean RightchildSent; //...
         public boolean ParentSent; //...
         //constructor
         public Node(int value, boolean LeftchildSent, boolean RightchildSent, boolean ParentSent, Node left, Node right)
              this.value = value;
              this.LeftchildSent = false;
              this.RightchildSent = false;
              this.ParentSent = false;
         //implements comparable
         public int ComparableTo(Node n)
              if(value < n.value) return -1;
              if(value == n.value) return 0;
              if(value > n.value) return 1;
    }anybody help, thanks very much

    Be sure to:
    1- Use a JRE System Library 5.0+ for your project.
    (Properties / Java Build Path / Libraries)
    2- Use a compiler compliance level 5.0+ for your project.
    (Properties / Java Compiler / Compiler Compliance Level)
    3- Change your last method to:    public int compareTo(Node n) // *** bad name used
            if(value < n.value) return -1;
            if(value > n.value) return 1;
            return 0; // *** be sure to have a return statement
        }or better:     public int compareTo(Node n)
            return value - n.value;
        }

  • Generic addAll problem

    I have the following problem with the generics (working in netbeans 3.3.1)
    The following nongeneric code works perfectly (of course):
    public class ABC {
        List mStrings;
        void addList(List a)    {mStrings.addAll(a);}
    }However, when I change it to generics:
    public class ABC {
        List<String> mStrings;
        void addList(List<String> a)   {mStrings.addAll(a);}
    }I get the following error
    ABC.java [20:15] cannot resolve symbol
    symbol : method addAll (java.util.List<java.lang.String>)
    location: interface java.util.List<java.lang.String>
    It is possible to fix the addList method in the following way (casting mStrings on List or Collection):
         void addList(List<String> a)   {((List)mStrings).addAll(a);}      Is'nt it strange? Or is there any more simple way to do it?
    Jiri Hana

    I could not reproduce this problem in the latest generics prototype.

  • Generic delta problem : in init load, the request is in yellow.......

    Hi all,
    I have created a table in R/3, and created a Generic data source using this table, and coming to deltas, i have selected Numeric pointer in which I have given the sales document number which comes from the table as the Delta relevant field. And the other things like replication, creation of info source, info package did well and I als got Initialization option in Info Package, but when I schedule the load, its coming in yellow signal and says that 0 records from 0 records, and gives error message as no records in the source system. This is the case if I use Init option in Info package.
    If I use Full load option in info pack, every thing is fine and I am able to extract the data from R/3 with out any problem, the load is getting succeeded.
    The only problem is with deltas. Is there anything else to do on R/3 side to enable the delta mechanism? or is it required to use functional module to enable the deltas ( I read this in some posts)? Please give me some solution.
    Thanks
    Ganesh

    Hi,
    There is no need to make any settings of delta...in general..it should work as similar as your full load....try to locate the problem area..and revert...
    Advise, check if there are any previous init. and delete...otherwise create a new
    infopackage and try..
    Cheers,
    Pattan.

  • TreeSet Comparator problem

    I've been working on a pathfinding algorithm and have been using a TreeSet with a custom comparator, but seem to have run into a problem. I'm under the assumption that a set should only contain one of each item based on the comparator. For some reason, when I do certain test cases the TreeSet will contain duplicate values. I specify that the values are equal if x == x and y == y, but somehow multiple x,y pairs are contained in the set. I use TreeSet.conatins() to determine if I should put the item in the list, but for some reason even if they share the same x,y pair it puts the same item in the list. Also, on other test cases its having trouble putting the items in the correct order. A pair of coordinates with a higher F value is in the front of the list when it should be in the back. If anyone has some suggestions i would greatly appreciate it. This is my code for the comparator. Maybe I'm doing something wrong and fresh set of eyes could help. This is my first time working with them and I'm not sure if I've made a tiny mistake or not.
    This is the custom comparator class I've implemented
        private class AStarNodeComparator implements Comparator<AStarNode>{
            public int compare(AStarNode o1, AStarNode o2) {
                return (o1.compareTo(o2));
        }And this is the compareTo, equals and hashCode method I've used for my AStarNode
        @Override
        public boolean equals(Object o){
            return(o instanceof AStarNode && this.compareTo((AStarNode)o) == 0);
        @Override
        public int hashCode() {
            int hash = 3;
            hash = 83 * hash + this.x;
            hash = 83 * hash + this.y;
            return hash;
        public int compareTo(AStarNode t) {
            if(this.x == t.getX() && this.y == t.getY()){
                return 0;
            else if(this.f < t.getF()){
                return -1;
            else{
                return 1;
        }If anyone has an idea on why this isn't sorting corectly and why it has duplicate items I would appreciate it.

    Would that exclude a value from the tree if the x and y didnt equal but the f values did? Say 1,3 = 110 and 1,2 = 110. Would it exclude one of the coordinates with that final return 0 at the end?No. It's the most minor key. It sorts items with equal (x,y) pairs only.
    I'm trying to keep duplicate x,y pairs out and sort them by f values at the same time.That is a contradiction in terms. If they are out how can you sort them? You have a major conceptual confusion here.
    Hmm would their be a different data structure I could use that would efficiently let me store them using the x,y coordinates as positions and then find the smallest one?It's not a question of which data structure, it's a question of how you are defining your ordering.
    I think your comparator should look like this:
    // Major key is 'x'
    if (this.x > that.x)
      return 1;
    if (this.x < that.x)
      return -1;
    // Sub-major key is 'y'
    if (this.y > that.y)
      return 1;
    if (this.y < that.y)
      return -1;
    // minor key is 'f'
    if (this.f > that.f)
      return 1;
    if (this.f < that.f)
      return -1;
    // Everything is equal
    return 0;As you are using a TreeSet you can throw away your hashCode() method. Otherwise it should take the 'f' value into account too.

  • String compare problem

    I try to compare 2 strings with compareTo/equalTo, but it's not working, those 2 funcs always return ture.
    public boolean chMark(String name, String test, String newMark)
              boolean flag = false;
              for(int i = 0; i < course.getNumOfStd(); i++)
                   if(course.getStd().getName().compareTo(name)==0)//here is problem;
                        Student tempStd = course.getStd()[i];
                        for(int j = 0; j < tempStd.getMark().getNumOfTests(); j++)
                        if(tempStd.getMark().getTestArray()[j].getTitle().compareTo(test)==0);//here is problem;
                             int mark = Integer.parseInt(newMark);                    }
              return flag;
    Can anybody tell me why?
    REGARDS,
    Elton

    equals() would read more naturally than compareTo()==0. But, in
    either case, use System.out.println() to write the two strings before
    you compare them. This is to check that you are comparing what
    you think you're comparing.System.out.println("name from course is " + course.getStd().getName());
    System.out.println("name is " + name);
    if(course.getStd()[i].getName().compareTo(name)==0)//here is problem;
    System.out.println("name from couse and name compared equal");
    // etc

  • CVS Compare Problem

    Hello,
    I'm using JDev 10.1.0.3.4.3673 and CVSNT2.0.8
    When I try to compare a file with another revision, the left filter defaults to the previous revision, and the right filter defaults to the head revision, but underneath the two filters where I expect to see the two source files and the differences from the comparison I just see a white background with the message 'Compare Not Available'.
    Does anybody have any suggestions how to solve this? Am I doing something wrong? This is really a show stopper for me.
    JFYI If I use the feature 'Compare With Other File', it works as expected. But of course my goal is to compare with other CVS revisions to see what changes a colleague has made.

    Thanks again for your help.
    I see this problem on all files that I try to compare from CVS. Below is the ouput from 'cvs log' from the command prompt for an example file. The date format is exactly as you described:
    RCS file: /local/reps/acc-dm/measdb/measdb-client-api/src/java/cern/measurement/MeasurementManager.java,v
    Working file: MeasurementManager.java
    head: 1.10
    branch:
    locks: strict
    access list:
    symbolic names:
    V2_0_1: 1.10
    V2_0_0: 1.10
    V1_5_14: 1.9
    V1_5_13: 1.9
    V1_5_12: 1.9
    V1_5_11: 1.9
    V1_5_10: 1.7
    V1_5_9: 1.6
    V1_5_8: 1.6
    V1_5_7: 1.6
    V1_5_6: 1.6
    V1_5_5: 1.6
    V1_5_4: 1.6
    V1_5_3: 1.5
    V1_5_2: 1.5
    V1_5_1: 1.5
    V1_5_0: 1.4
    V1_4_0: 1.3
    V1_3_0: 1.2
    V1_2_1: 1.1.1.1
    V1_2_0: 1.1.1.1
    V1_1_0: 1.1.1.1
    V1_0_1: 1.1.1.1
    V1_0: 1.1.1.1
    arelease: 1.1.1.1
    avendor: 1.1.1
    keyword substitution: kv
    total revisions: 11; selected revisions: 11
    description:
    revision 1.10
    date: 2006-06-08 15:06:32 +0000; author: konkere; state: Exp; lines: +172 -107; commitid: lnQP1pTMGnOrhdAr;
    JMON-52.
    Refactoring to generalize the fundamental and measurement variable behaviour and handling
    revision 1.9
    date: 2006-04-07 09:57:02 +0000; author: cdroderi; state: Exp; lines: +76 -16; commitid: AiECvh7J3qGRydsr;
    New Fundamental Variable Features, and SavedVariableList for integration with
    Set Of The Day.
    revision 1.8
    date: 2006-01-25 18:19:54 +0000; author: cdroderi; state: Exp; lines: +3 -4;
    Added additional debug information to verify clearing of timeseries data
    revision 1.7
    date: 2006-01-17 14:33:53 +0000; author: cdroderi; state: Exp; lines: +29 -0;
    [no comments]
    revision 1.6
    date: 2005-09-15 20:12:15 +0000; author: cdroderi; state: Exp; lines: +0 -0;
    [no comments]
    revision 1.5
    date: 2005-09-12 08:01:07 +0000; author: cdroderi; state: Exp; lines: +2 -2;
    Extended MetaVariableSet extraction using MetaHierarchy to include all nodes under the node represented by the given hierarchy.
    revision 1.4
    date: 2005-08-30 21:13:04 +0000; author: cdroderi; state: Exp; lines: +24 -3;
    Limited the variable ownership and registration checks to once per session unless variables are added or removed from a variable set.
    revision 1.3
    date: 2005-08-30 14:25:10 +0000; author: cdroderi; state: Exp; lines: +50 -3;
    New methods to read MetaVariableSet objects using a given MetaVariable name pattern or MetaHierarchy to filter the size of the returned set.
    revision 1.2
    date: 2005-08-23 14:16:25 +0000; author: cdroderi; state: Exp; lines: +19 -15;
    Bug fix for writing data for variables with no time series data. Merge data when duplicates are found.
    revision 1.1
    date: 2005-06-01 17:52:43 +0000; author: cdroderi; state: Exp;
    branches: 1.1.1;
    Initial revision
    revision 1.1.1.1
    date: 2005-06-01 17:52:43 +0000; author: cdroderi; state: Exp; lines: +0 -0;
    no message
    =============================================================================

  • TreeSet and Comparator problem

    Hi all ,
    I am using jdk1.3 , jbuilder4.0 , Apache Tomcat 1.3.14 and Window 98 and Access Database.
    I have comparator code below which give me some problem
    public int compare(Object x, Object y) {
    CompanyJB a = (CompanyJB)x , b = (CompanyJB)y;
    double aMinratio = a.getMinratio();
    double bMinratio = b.getMinratio();
    int aCompid = a.getCompanyid();
    int bCompid = b.getCompanyid();
    String aRankstr = a.getRank();
    String bRankstr = b.getRank();
    int tmp;
    tmp = new Integer(aCompid).compareTo(new Integer(bCompid));
    if (tmp == 0) {
    return tmp;
    tmp = a.getRank().compareTo(b.getRank());
    if (tmp !=0) {
    return tmp;
    tmp = new Double(a.getMinratio()).compareTo(new Double(b.getMinratio()));
    if (tmp !=0) {
    return tmp;
    return new Double(a.getMinratio()).compareTo(new Double(b.getMinratio()));
    Client source code below :
    TreeSet list2 = new TreeSet(new test());
    //list2.add(new test(2,1.9,4.2,"NA")); // 1
    list2.add(new test(11,8.5,8.5,"2")); // 3
    list2.add(new test(1,0.6,0.6,"NA")); // 2
    list2.add(new test(11,2.5,2.3,"NA")); // 4
    list2.add(new test(12,0.3,0.3,"1")); // 5
    list2.add(new test(2,1.9,1.2,"NA"));
    list2.add(new test(12,0.9,0.9,"NA"));
    Iterator iterator2 = list2.iterator();
    while(iterator2.hasNext()){
    System.out.println(((test)iterator2.next()).getCompanyid());
    My problem is that the print out display duplicate company id "12" in the set.
    It should not display the duplicate company id in the set.
    What is the problem here ?? Anybody have ideas ??

    Actually, a Set, as defined in java.util.Set, should not contain duplicate members. With SortedSets, however, there must also be consistency between equals() and the compareTo() (or Comparator.compare()). In other words, equal objects must sort to the same or an adjacent place in order for the Set semantics to work.
    In your example, "equal" objects can appear in completely different positions in the sort order, throwing off this consistency. When adding, it's traversing the tree in Rank,MinRatio order. If by chance it runs across a node that has the same company id, it stops and leaves the trees alone (as it does with id=11). If you try graphing the tree out by hand using your compare() as left/right criteria (negative left, positive right, 0 don't change), it'll become immediately clear what's happening.
    Also of interest: you'll find that you can't add test(34,1.9,1.2,"NA") to the list: because it's Rank and MinOrder is the same as the id=2 entry, it'll never get added.

  • Generic Comparator compile issue

    hi
    In JDeveloper 10.1.3.2.0.4066 this code ...
    package genericcomparatorcompileissue;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.LinkedList;
    import java.util.List;
    public class GenericComparatorCompileIssue
         private static interface MyRow {};
         private static class MyRowImpl implements MyRow {};
         private static class MyRowComparator implements Comparator<MyRowImpl>
              public int compare(MyRowImpl pFirstMyRowImpl, MyRowImpl pSecondMyRowImpl)
                   return 0;
         public static void main(String[] pArguments)
              System.out.println("GenericComparatorCompileIssue.main() : begin");
              List<MyRow> vMyRowList = new LinkedList<MyRow>();
              Collections.sort(vMyRowList, new MyRowComparator());
              System.out.println("GenericComparatorCompileIssue.main() : end");
    }... compiles and runs and produces this output:
    GenericComparatorCompileIssue.main() : begin
    GenericComparatorCompileIssue.main() : endBut if you check the "Use Javac" Compiler option in the Project Properties dialog, the compiler reports a "cannot find symbol" error at line 25.
    How can this be explained?
    many thanks
    Jan Vervecken

    This problem has been reported as
    BUG 6311332 - OJC ALLOWS WRONG PARAMTERS FOR COLLECTIONS.SORT(...)
    This bug will be fixed with JDeveloper 11. (It is not yet fixed with the development preview!)
    As a workaround you can use javac instead of ojc for compilation. javac will report such wrong assignments. You need to compile with ojc only if you want to use JDeveloper profiling or code coach.

  • Generic comparator in container search

    I have an application where I'm using a Stack to store heterogeneous objects, some of which might be Comparable. I occasionally have need to search(obj) the stack for some object that might or might not be there. The object might be comparable.
    I have one particular class (which shall remain anonymous) whose comparator, in a wonderful display of software engineering theory, throws an IllegalArgumentException when compared to something it can't compare to, instead of returning false.
    Now it would be nice to be able to just send a Comparator to the search() method (or to any other container's lastIndexOf(), etc.) so that I can do some arbitrarily smart comparison, or arbitrarily stupid one. Why can't I?!?!?!!
    Now in this case, what I've resorted to doing is writing a wrapper class that has a compareTo method that compares class strings first, then catches such silly things if they happen.
    Is there an easier way? Should I submit a feature request for these comparing methods to optionally take a Comparator?
    Thanks,
    Gremio

    Why can't I?!?!?!!Because not all the objects in the stack might be Comparable. Because the search method is designed to look for an object - with identification by equals.
    Is there an easier way? Sure, violate the equals() contract and pass into search an object which returns true when equals is called with any object you're interested in.
    By the way, please tell your software engineering theorist that the API says (s)he should throw ClassCastException.

  • Generic Extraction Problem

    HI There,
    I am trying to creat grneric extractor (with Table) on MBEW table .while i saving it is not saving.it is showing some some error .
    *ERROR IS
    Diagnosis
    You tried to generate an extract structure with the template structure MBEW. This operation failed, because the template structure quantity fields or currency fields, for example, field LBKUM refer to a different table.
    Procedure
    Use the template structure to create a view or DDIC structure that does not contain the inadmissable fields.*
    As per my understanding we can't creat table type generic extractor ..we can creat a view on that table then only we creat gerneric extractor with view.
    Is my understanding correct..? or is there any onther assumption for the error.
    Plz assist me.
    Regards...KP

    H there..
    Thank you for the great responce...
    As in the error...In  MBEW table all the unit fields i,e  currency unit fields( WAERS) are coming from T001 table and quantity unit fields (MEINS) are coming from MARA table.
    i am thinking to creat a view with MBEW,MARA and T001 tables.i will seclect the char and key filelds from MBEW and related unit fields from MARA and T001.
    i guess this would be the solution..plz respond.
    Regards...KP

  • Generic delta problem

    Hi all,
    If suppose we don,t have delta facility in generic extraction on R/3 for Master Data. how can we maintain the delta for that one in BW.
    Thanks & Regards,
    Sri

    hi Sri,
    suppose we don't ...
    i think you can try flexible update for master data and via ods, create ods with same structure and key as the master data, create infosource for the ods, upload data to the ods.
    and set the master data as 'infoprovider', create update rules assign from the ods. so the 'delta' is handled by ods. hope this helps.

  • Generic unchecked problem

    Hi All,
    I have a problem with the following code . Can any one help me to over come the warning.
    Here is my code:
    import java.util.*;
    public class CastEx {
    public CastEx() {
         Vector<String> v1 = new Vector<String>(); // ok
         Object obj = (Object) v1; // ok
         Vector<String> v2 = (Vector<String>) obj ; //unchecked cast
    public static void main(String[] args) {
         new CastEx();
    Warning :
    CastEx.java uses unchecked or unsafe operations.
    Thanks in advance........

    You have some choices:
    1- Learn to live with the warning.
    2- Use the annotation @SuppressWarning("unchecked") before the method or class.
    3- Don't do this type of unchecked cast in your code.
    4- Use another cast:Vector v2 = (Vector) obj;Regards

  • Function module based generic extractor - Problem with the selection

    Hi all
    The following is my code in the function module. I am able to get the entire data if i dont give any selections and the number of records is also correct. But when i select a MATNR value, it returns 0 records where as it needs to return 3 records. If i give selection based on bukrs, werks, lgort its working fine. But if i give selection based on MATNR, then it is not working.... I think there is a problem in the bold part of my code. If i debug, LS_MATNR is having the correct value which indicates that there is no problem with the value being passed to LS_MATNR from my selection screen of my datasource in RSA3. Even GT_WERKS is also having data. Please help.
    OPEN CURSOR WITH HOLD S_CURSOR FOR
    SELECT  MARA~MANDT
            MARA~MATNR
            MARC~WERKS
            MARD~LGORT
            MARA~MEINS
            MARD~LABST
            MARD~EINME
            MARD~SPEME
            MARD~RETME
            MARD~INSME
            MARD~UMLME
            MARD~VMLAB
            MARD~VMEIN
            MARD~VMSPE
            MARD~VMRET
            MARD~VMINS
            MARD~VMUML
            MARC~XCHPF
            MARD~KLABS
            MARD~KEINM
            MARD~KSPEM
            MARD~KINSM
    from MARA inner join MARC on
    MARAMANDT = MARCMANDT AND
    MARAMATNR = MARCMATNR
    inner join MARD on
    MARAMANDT = MARDMANDT AND
    MARAMATNR = MARDMATNR
    AND MARCWERKS = MARDWERKS
    for all entries in gt_werks
    where MARC~werks EQ gt_werks-werks
    AND MARA~MATNR in LS_MATNR.
        ENDIF.                             "First data package ?
    Fetch records into interface table.
      named E_T_'Name of extract structure'.
        FETCH NEXT CURSOR S_CURSOR
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE E_T_DATA
                   PACKAGE SIZE S_S_IF-MAXSIZE.

    try this
    select marc~matnr MARC~WERKS into t_marc for all entries in gt_werks
    where werks EQ gt_werks-werks and lvorm = space.
    if t_marc is not initial.
    select MARD~LGORT MARD~WERKS MARA~MEINS MARD~LABST MARD~EINME
    MARD~SPEME MARD~RETME MARD~INSME MARD~UMLME
    MARD~VMLAB MARD~VMEIN MARD~VMSPE MARD~VMRET
    MARD~VMINS MARD~VMUML MARC~XCHPF MARD~KLABS
    MARD~KEINM MARD~KSPEM MARD~KINSM  MARA~MEINS  from
    mard inner join MARA on mard~matnr = mara~matnr
    for all entries in t_marc where  mard~matnr = t_marc-matnr and mard-werks = t_marc-matnr
    and mard~lvorm = space.

Maybe you are looking for

  • //remove this line if you want to edit the code by hand? um which line?

    Several of my pages are locking up and I don't know why. As I work through the code, I remembered that I altered some text in a SendEmail by directly altering the page rather than using the Server Behavior. Don't understand why that would matter but

  • Converting byte to string

    Im doing a CRC for a txt file. So after the CRC calculation i got the 16bit check sum. How should i add the 16 bit to the file? The file is generated base on various objects. So it would be very good if i could convert the 16 bits into String and the

  • Java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicati

    Hi, I have an application which is executing properly in jboss 3.2.5 but as we are trying to upgrade the jboss version i am getting above mentioned error. The application is deployed in jboss as an ear file and the ear contains one jar file that has

  • I can't connect ipad mini to att wire2

    My ipad mini won't connect with my ATT&T wireless router wire2  I have  2 iphones that work fine

  • Importing XDP form in SAP Adobe Form Builder

    Hello,    In SAP transaction SFP to create Adobe form, there is an option to import an existing form from Designer 5.0 .xft files or .pdf files. Is there any way I can import Designer 6.0 (.xdp files) onwards forms into SAP ? Thanks, Anjali