Implementing FEB_BADI and CHANGE_POSTING_DATA method

According to OSS note 494777, I would use FEB_BADI for inserting additional line items in EBS. I have no experience in BADI. Did somebody already use this BADI ? Can you give me a step by step description of the necessary actions for implementing it ?
Thanks in advance.

What is the source code you use for the method?
According to note 190298, here is the excerpt...
"...As of Release R/3 Enterprise 4.70, a modification is no longer necessary. Instead, you can change the system behavior as described by implementing a BAdI. You can use the BAdI MD_CHANGE_MRP_DATA to change MRP data. In planned orders for stock transfer, purchase requisitions and purchase orders, the activation of the delivered example source code for the methods CHANGE_MDPSX_MDUP, CHANGE_MDPSX_MDUA, and CHANGE_MDPSX_MDUB means that the release requirements are no longer MRP-relevant. We recommend that you use the BAdI solution. (This BAdI also replaces the described modification)."
The sample source code for method CHANGE_MDPSX_MDUA to do so is:
Makes stock transport purchase requisitions not availability-relevant
*--> substitutes part of the modification of note 190298.
For the other parts the same has to be made in methods:
CHANGE_MDPSX_MDUP for stock transport planned orders
CHANGE_MDPSX_MDUB for stock transport orders.
*--> delete flag for availability
  clear ch_mdps-vrfkz.
*--> set changing flag
  ch_changed = 'X'.
endmethod. "IF_EX_MD_CHANGE_MRP_DATA~CHANGE_MDPSX_MDUA
Please give it a try.  Hope it helps.

Similar Messages

  • WebLogic 10.3 doesn't implements equals() and hashCode() for TimerHandle?

    Hi,
    I'm using WebLogic 10.3 and need to use TimerHandle to handle some logic in my application.
    Below is a scenario.
    At the time by creating EJB Timer, I've saved the TimerHandle for later use into Database along with specific name as a key.
    Then, at the time to execute/awaken timer I need to check that the saved TimerHandle is the same as passed Timer.
    @Timeout
    public void execute( final Timer timer )
    // getting key from passed object in timer.getInfo().
    // getting saved timerhandle by key. let's say dao.getXxxHandle(key);
    // perform checking.
    if ( timerHandle != null && timerHandle.equals( timer.getHandle() ) )
    // do sth.
    else
    //do another thing.
    The result is always drop in else block.
    By doing this is working on WAS7 and JBoss4xx (getting to if block). I was wondering if WebLogic doesn't implements equals and hashCode method then is there another way to check that the retrieved TimerHandle is the same one as timer.getHandle()?
    I'm thinking of adding some unique ID to see if timehandle is the same one or not? However as I mentioned, It works on WAS and JBoss. Does WebLogic has another way to handle my scenario?
    Any help would be appreciate.
    Thanks in advance,
    Nattachai W.

    As you have suggested, it looks like we don't override the equals() method on either our local or clustered TimerHandle implementations.
    We opened a bug (9558396) so we can address it in a future patchset.
    In the meantime, if you have an Oracle support contract, you could open a service request and ask for a patch for bug 9558396 to be created.
    -steve-

  • How to implement classes and methods in badi's ?

    how to implement classes and methods in badi's? and where i have to write the code based on the requirement?can anyone explain me briefly?

    Hi
    Every BADI by default Implements an INTERFACE which already contains some methods with parameters.
    So you have to find the relavenet method based on the related paramters (by checking the fields in that paramters) you have to double click on the method and to write the code.
    see the doc
    DEFINING THE BADI
    1) execute Tcode SE18.
    2) Specify a definition Name : ZBADI_SPFLI
    3) Press create
    4) Choose the attribute tab. Specify short desc for badi.. and specify the type :
    multiple use.
    5) Choose the interface tab
    6) Specify interface name: ZIF_EX_BADI_SPFLI and save.
    7) Dbl clk on interface name to start class builder . specify a method name (name,
    level, desc).
    Method level desc
    Linese;ection instance methos some desc
    8) place the cursor on the method name desc its parameters to define the interface.
    Parameter type refe field desc
    I_carrid import spfli-carrid some
    I_connid import spefi-connid some
    9) save , check and activate…adapter class proposed by system is
    ZCL_IM_IM_LINESEL is genereated.
    IMPLEMENTATION OF BADI DEFINITION
    1) EXECUTE tcode se18.choose menuitem create from the implementation menubar.
    2) Specify aname for implementation ZIM_LINESEL
    3) Specify short desc.
    4) Choose interface tab. System proposes a name fo the implementation class.
    ZCL_IM_IMLINESEL which is already generarted.
    5) Specify short desc for method
    6) Dbl clk on method to insert code..(check the code in “AAA”).
    7) Save , check and activate the code.
    Some useful URL
    http://www.esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://www.esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://www.esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://www.esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    www.sapgenie.com/publications/saptips/022006%20-%20Zaidi%20BADI.pdf
    http://www.sapdevelopment.co.uk/enhance/enhance_badi.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/d54d3c596f0b26e10000000a11402f/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/eab541c5b63031e10000000a155106/frameset.htm
    Now write a sample program to use this badi method..
    Look for “BBB” sample program.
    “AAA”
    data : wa_flights type sflight,
    it_flights type table of sflight.
    format color col_heading.
    write:/ 'Flight info of:', i_carrid, i_connid.
    format color col_normal.
    select * from sflight
    into corresponding fields of table it_flights
    where carrid = i_carrid
    and connid = i_connid.
    loop at it_flights into wa_flights.
    write:/ wa_flights-fldate,
    wa_flights-planetype,
    wa_flights-price currency wa_flights-currency,
    wa_flights-seatsmax,
    wa_flights-seatsocc.
    endloop.
    “BBB”
    *& Report ZBADI_TEST *
    REPORT ZBADI_TEST .
    tables: spfli.
    data: wa_spfli type spfli,
    it_spfli type table of spfli with key carrid connid.
    *Initialise the object of the interface.
    data: exit_ref type ref to ZCL_IM_IM_LINESEL,
    exit_ref1 type ref to ZIF_EX_BADISPFLI1.
    selection-screen begin of block b1.
    select-options: s_carr for spfli-carrid.
    selection-screen end of block b1.
    start-of-selection.
    select * from spfli into corresponding fields of table it_spfli
    where carrid in s_carr.
    end-of-selection.
    loop at it_spfli into wa_spfli.
    write:/ wa_spfli-carrid,
    wa_spfli-connid,
    wa_spfli-cityfrom,
    wa_spfli-deptime,
    wa_spfli-arrtime.
    hide: wa_spfli-carrid, wa_spfli-connid.
    endloop.
    at line-selection.
    check not wa_spfli-carrid is initial.
    create object exit_ref.
    exit_ref1 = exit_ref.
    call method exit_ref1->lineselection
    EXPORTING
    i_carrid = wa_spfli-carrid
    i_connid = wa_spfli-connid.
    clear wa_spfli.
    Reward points for useful Answers
    Regards
    Anji
    Message was edited by:
            Anji Reddy Vangala

  • Scenario in which implement or Write our own hascode and equals method

    Dear All,
    Please let me know in which circumstances we write our own Hashcode method and equals method not the default one provided by java.Kindly give me complete code and scenario.
    Thanks
    Sumit

    Thanks for your reply
    I have one more question.
    When equal method of Object class give the same result as equals we override then why should we override equals.For example see the below code
    public class EqualsTest{
    public EqualsTest() {
         super();
    public static void main(String[] args) {
    Moof one =new Moof(8);
    Moof two =new Moof(8);
    if(one.equals(two))
    System.out.println("one is equals to two");
    class Moof {
    private int moofvalue;
    Moof(int val){
    System.out.println("val inside moof constructor"+val);
    moofvalue=val;
    System.out.println("moofvalue inside moof constructor" +moofvalue);
    public int getMoofValue()
    System.out.println("moofvalue inside getmoffvalue method "+moofvalue);
    return moofvalue;
    public boolean equals(Object o)
    System.out.println("Object o in equals"+o);
    if( (o instanceof Moof) &&(( (Moof)o).getMoofValue()==this.moofvalue))
    System.out.println("true");
    return true;
    else
    System.out.println("false");
    return false;
    Here the output we get is :
    val inside moof constructor8
    moofvalue inside moof constructor8
    val inside moof constructor8
    moofvalue inside moof constructor8
    Object o in equalsMoof@119c082
    moofvalue inside getmoffvalue method 8
    true
    one is equals to two
    The last output "one is equals to two" gives the same result as overridng equals by us.So why should we override equals here.
    Thanks
    Sumit

  • Dynamic creation of class and calling methods

    I've got and interface called Transformation and then two implementations called TxA and TxB, where TxA and TxB have their own attribtues and setter and getters for these attributes.
    The question is, I need to create instances of TxA and TxB and called the setter and getters where I at runtime I only know the attribute to set, how can I create and instance and call the right getters and setters methods?
    Thanks in advance

    Smart money says your design sucks and needs to be rethought entirely. Can we get specifics?
    Drake

  • Multiple dispatch and Symmetric methods - Where Does That Code Live?

    Hi all.
    I am stuck with the above problem, which looks to be a very common and fundamental one. Supposing I have some sort of relation or operation to be performed on various different pairs (or n-tuples) of classes of object. Where does this code belong, given that it is not sole property of any one of the classes, but a kind of property of the collection of classes?
    An bad example for me to bring up, but one that neatly illustrates the point, is the equals method. In order to retain the symmetric and transitive properties of the equals method, and object can only make judgement calls about it being equal to another object of it's own type. This prevents the concept of equivalency from crossing between types.
    In order to compare a with b (if a and b are of different types), b must supply some sort of representation of itself as an a, then the comparison statement a.equals(b.asA()); must be called.
    This of course means b must supply an 'asXXX()' method for each class XXX it wishes to equate itself to. Furthermore, by an extension of the equals contract for symmetricality, the method AsB() in class A (if it exists) must be such that, if a.AsB() .equals (b), then b.AsA.equals( a ).
    This sort of design is unfeasible for obvious reasons, the main reason being that it is impossible to anticipate evey case where an instance of class A could reasonably be compared to an instance of some other class X.
    The other annoyance is all that hard work of providing methods to equate A with something else, would go unused for 99% of the time.
    With this in mind, I was thinking. Suppose in some program environment, we have only 3 classes, A, B, and C, such that:
    {A,B} can be meaningfully compared
    {B, C} and {A, C} cannot.
    It would be OK to supply code (somewhere) for comparing A's with B's. We also know that under no circumstances will an A or a B, and a C, ever need to be compared for equality.
    Supposing an extension of this environment were created, introducing class D.
    {D, A} and {D, B} can be meaningfully compared.
    Now, neither A nor C knows what a D is, or how to compare themselves to it. But D was developed with A, B and C in mind, and contains logic for the various comparisons (with A and with B). An obvious idea for this is to let D bring it's new code into play, by registering these new comparison functions in the environment somehow.
    Supposing instead that equality comparison was delegated to some third party, instead. This third party contains a table of pairs of classes, which act as keys to look up a comparison object.
    So, when class A is loaded, something of the sort happens:
    public class A {
        static {
            Equals.comparer.addEntry(A.class, B.class, new EqualsMethod() {
               // details of the EqualsMethod interface implementation go here
    public class B {
        static {
            // since equals is symmetric, this method clashes with the above in A
            // This could happen...
            Equals.comparer.addEntry(B.class, A.class, new EqualsMethod() {
               // ... different approach to the above
    public class D {
        static {
            Equals.comparer.addEntry(D.class, A.class, new EqualsMethod() {
            Equals.comparer.addEntry(D.class, B.class, new EqualsMethod() {
        } // Ds can now be compared with Bs and As. They can now be compared with Ds
    }There is a problem with the above. As can clearly be seen, there are 3 unique situations that might occur between two classes (call them X and Y).
    o One of X or Y contains code to compare them both.
    o Neither X nor Y contain code to compare the two. X equals Y is always false
    o Both X and Y contain code to compare the two.
    The third causes the problem. What if X and Y disagree on how to compare themselves? Which method gets chosen? The only solution would be to let whosever static initialiser gets called first be the one to supply the code.
    I said before that equals was a bad example to bring up. this is because the usage of equals and the concept of equality in java is already well defined, and works just fine. However, in my own pet project at the moment, I have run into the same problems as outlined above.
    I am currently assembling a generic pattern API for use in various other applications I am writing (I was finding that I was writing code for matching objects to patterns, in different guises, quite frequently, so I made the decision to refactor it into its own package). An important part of the API is the section that handles the logic for combining patterns, ie with AND, OR and NOT operations.
    The Pattern interface is this:
    interface Pattern<E> {
         public boolean match(E toMatch);
         public Pattern<E> not();
         public Pattern<E> or(Pattern<E> other);
         public Pattern<E> and(Pattern<E> other);
    }There are a few basic Patterns:
    TruePattern<E> - a pattern that always returns true no matter what E is passed for it toMatch
    FalsePattern<E> - self-explanatory.
    ExactValuePattern<E> - true if and only if the E that it is passed toMatch is .equal to the E that this pattern was constructed with.
    NotPattern<E> - a pattern that contains another pattern, and returns true for any E that returns does not match it's contained pattern. Used for when the contained pattern cannot be logically reduced to one pattern under the NOT method in the Pattern interface
    AndPattern<E> - a pattern that contains 2 other patterns, and returns true for some E iff both contained patterns return true for that E. Used for when the 2 patterns cannot be logically reduced into one pattern via the AND method in the Pattern interface
    OrPattern<E> - self explanatory
    RangePattern<E extends Comparable <E>> - a pattern for comparing if some Comparable lies between two other comparables.
    Every pattern has the opportunity to provide a reduction, when combined with another pattern through And or Or. For example, any pattern AND a FalsePattern can be reduced just the FalsePattern. any pattern OR a TruePattern can be reduced to just the TruePattern.
    The methods AND and OR from the Pattern interface present the same problems as the .equals() example I was using before.
    o AND and OR are symmetric operations
    o There exist situations where two patterns of unrelated class could be meaningfully combined (and reduced) under these two operations.
    Example: The pattern on Integers '0 < X < 3' and 'X is 5' can be reduce to the FalsePattern
    Example: The pattern on Doubles '0 < X <= 10' or 'X is 5.5' or 'X is 7.2' can be reduced to '0 < X <= 10'.
    Example: The pattern on Integers ('0 <= X <= 5' and 'X is not 0') or ('X is 6') or ('x is 7') can be reduced to '1<=X<=7'.
    So the question is, where does the code belong? a.and(b) should return the same as b.and(a), but both b and a may well disagree as to what happens when they are combined under and. At present, both a and b need to supply their own separate implementations. Clearly though, the code for combining patterns A and B belongs to neither A alone, not B alone, but to A and B as a whole.
    Thanks in advance, and sorry for this overlong post.

    So the equivalent thing in my scenario would be an
    AndAnator, and an OrAnator? :)
    The thing is, it would be nice for comparison between
    A and B to take place automatically, without the poor
    coder having to maintain a reference to a Comparator
    and invoke the comparison method each time. Likewise
    in my situation, it'd be nice to say A.or(B) instead
    of andAnator.and(A,B), yet have all the goodness of a
    third party doing the comparison (or in this case,
    the anding).
    I am going to go and test this all out, but do you
    have any suggestions on a good structure? I think it
    would involve pulling the and/or/not methods from the
    interface (this appeals, as many implementors may not
    wish to supply logic for running these methods
    anyhow), and then putting them... somewhere else.I didn't consider your speicifc problem very deeply because after such a long detailed explanation I figured you'd be up for kicking around the idea for a while.
    In your case, I see that you would want to be able to call the and and or methods on the Objects themselves. Luckily, in this case, I think you can have your cake and eat it too.
    You can make your and and or methods fa�ades to the third party 'referee'. This way you can enfore symmetry. It's difficult (if not impossible) to enoforce transitivity with this design but I think you don't even need that in this case. That is if a == b and b == c then a == c should be true but if a and b and b and c then a and c is not necessarily true. In your case, it may not even make sense.

  • Why do we need get and set methods?

    It is considered good design practice to keep all class data private and
    provide get and set methods for accessing the data in a controlled
    manner.
    So, instead of directly accessing the class data, you use getter and setters.
    I do not really feel the need to use get and set methods.
    How does that achieve encapsulation when ultimately the class data is being exposed?

    A couple of reasons why to use get and set:
    1. For example you can set an int value for month, if a user sets this to somting
    higher than 12 (or 11 if it's zero based) you want to handle that by either
    throwing an exception or adding a year for every time it can be devided by 12.
    If you dont do it in set you'll have a whole bunch of methods that might need to
    correct the value before retreiving the eventual date.
    2. If for some reason you have security set up for certain values you can
    implement this in the get method. When this is done somewhere else you have
    a whole bunch of methods retreiving the info in other classes that need to check
    first. (a canGet method could allso be used). Another good reason to use get
    is when the information needs to be converted depending on the consumer
    calling the get method.
    3. If any logic in 1 or 2 changes you'll have a bunch of code to change.
    If you feel there is no need to implement any security, error handling (on
    compiling because get and set might throw something) or validation when
    setting/getting these values there is still the argument of readabillity.
    Eclipse has a feature that will generate getters and setters for you so it's not
    like there is a lot of extra typing involved.
    Got interupted whyle typig so sorry to repeat any answer given before.

  • Design Patterns: 'Program to an interface, not an impl.' and Factory Method

    Design Patterns: 'Program to an interface, not an implementation' and Factory Method.
    Hi All,
    I've 4 questions. And 1M thanks for your precious input.
    1. OOAD steps:
    Requirement-->Use Cases-->Analysis Classes-->Sequence Diagrams-->CRC-->other UML diagrams if needed--> Domain/Business Classes.
    If we follow the rule 'Program to an interface, not an implementation',
    would that imply NECESSARILY we should have another set of Interface Classes for our Domain Classes? i.e Interface_ClassX for ClassX_Impl.
    2. If the point 1 is a MUST because of the rule 'Program to an interface, not an implementation',
    ie we should have an Interface classe for every one Domain classe,
    would that NECESSARILY imply we should have as many Factory Methods as they are Domain Classes to abstract the creation process?
    Interface_ClassX X= Factory.GetClassX() ( return new ClassX_Impl)
    Interface_ClassY Y= Factory.GetClassY() ( return new ClassY_Impl)
    Interface_ClassZ Z= Factory.GetClassZ() ( return new ClassZ_Impl)
    3. On the point 2, the underlying principle used is Factory Methods.
    Now on the surface, what are other possible business and/or technical naming for such Factory Methods? I mean should we call it a kind of Business Facade?
    4. Is the point 1 and point 2 considered to be the best practices?

    So the question here is whether we can predict having
    more than one possible implementations which required
    option c. Is this a dilema? I guess it's hard to
    predict the future.Right. Hopefully it's fairly obvious while designing things and
    deciding what objects are needed.
    Now, if the Presentation Tier, says JSP, needs that
    ClassNormal object. Would we still keep that line of
    code a.
    OR would we introduce an intermediate object to free
    JSP from the direct creational aspect using new
    keyword like the choice b. that you reject.
    The point here is to reduce the direct coupling aspect
    between the Presentation Tier and Business Tier. So
    what would that intermediate object be?In that case, you have to ask yourself if there is a valid
    need for reducing the coupling. If you simply make an intermediate
    object, what keeps you from making an intermediate object to your
    new intermediate object, ad infinitum.
    That intermediate object could be a Facade pattern, or simply
    an abstraction. We actually did that here, we began a massive
    java project, and we abstracted away from Swing J-classes and created
    our own "wrappers" that simply extended all the J-classes and we had
    all our programmers develop using our wrappers instead of the Swing
    classes. That allowed us to add some custom code, some temporary bug fixes, etc. Some of our classes were nothing more than "EPPasswordField extends JPasswordField" with nothing overridden. It does allow us a place to hook in and adjust or fix things if needed though.

  • Implementing Cash Flow (Indirect Method)

    Hi,
    Does anyone know what's required to implement Cash Flow (Indirect Method)? (T-code:S_ALR_87012272)
    Thanks,
    CW

    Hi Dan,
    Very interesting! Though, I didn't get the answer. Think it would be very favorable for everybody, if you explain in more details.
    AFAIK, data is stored in BCS periodically. So, do you imply that it's possible to create cash flow for any set of data in the system (because of periodicity)?
    Talk about ttypes and breakdown categories are also not very clear for me.
    Anyway, I'd like to talk functional, not SAP (or some other IT) language.
    Here we go.
    Did you say that you used to create the cash flow report on the fly, by using some calculations in BEx?
    And the same for eliminations in cash flow?
    Did you do eliminations in CF?
    If yes, then I would suggest that you were lucky, having local and group currency the same, USD?
    As BCS consultant knows, the indirect cash flow report consists of 3 parts: net cash flows from operating activities, finance and investing ones.
    NCF from operating activities is usually calculated as net profit (before or after taxes) with some corrections that are calculated as differences in reported-beginning balances on some accounts. Would you calculate them in local or group currency? Taking into account that there might be no real movement in cash (local currency), but currency rate has changed?
    Financial & investing activities MUST BE PROVIDED in direct sense, like: dividends received, interests paid for credits and loans etc. There is, usually, no such information, only some netted activities. You need to get them additionally. How did you get them?
    So, the main question is:
    how would you calculate the CONSOLIDATED INDIRECT cash flow report
    having different local currencies (and a different group currency), with some intergroup activities?
    Everybody will appreciate your input on this subject.

  • Implementation of the hasProperties() method of the Node class

    The following snippet of code prints:
    false
    true
    which seems to be a bug.
    TextField nameField = new TextField();
    System.out.println(nameField.hasProperties());
    ObservableMap<Object, Object> props = nameField.getProperties();
    System.out.println(nameField.hasProperties());The implementation of the hasProperties() method in the Node class returns true, if the ObservableMap object for storing properties has been created. That is not what is expected from this method. I think, this method should also check if the ObservableMap has any properties.
    Can someone confirm that it is a bug?
    Thanks
    Kishori

    You can log it at http://javafx-jira.kenai.com and then, if the developers want to keep it the way it is (which they may for API compatibility purposes), they can at least document it so that a user would know what to expect without writing a test or making a potentially invalid assumption.

  • How to refresh table display using slis and 'reuse_alv_grid_display method.

    hello,
    how to refresh table display using slis and 'reuse_alv_grid_display method'.
    when i'm refreshing table display it performs once again reuse_alv_grid_display.and when i back the previous value appear.how to solve it?
    neon

    are you chaning any value in the gird if so use this..
    Pass the user_command form name to the Import parameter
    I_CALL_BACK_USERCOMMAND .
    and have the Dynamic form implementation..
    FORM user_command USING ucomm TYPE sy-ucomm
                selfield TYPE slis_selfield.
    "The below is important for Editable Grid.
      DATA: gd_repid LIKE sy-repid, "Exists
      ref_grid TYPE REF TO cl_gui_alv_grid.
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data .
      ENDIF.
      CASE ucomm.
        WHEN 'REFRSH'.
      ENDCASE.
           selfield-refresh = 'X'.
    ENDFORM.                    "user_command

  • Please help, how to implement hasNext() and next() of a HashSet iterator?

    Hi guys,
    Can someone help me out with this? I'm struggling to write an iterator (the hasNext() and next() methods) for a SimpleHashSet class and I keep failing. I have a basic unit test, which goes like this:
    @Test
        public void testIterator() {
            SimpleHashSet<String> instance = new SimpleHashSet<String>();
            assertTrue(instance.iterator() != null);
            Iterator<String> it = instance.iterator();
            assertFalse(it.hasNext()); //Should return false on an empty HashSet
            assertTrue(it.next() == null); //Should return null on an empty HashSet
            instance.add("First");
            instance.add("Second");
            assertTrue(it.hasNext()); // Return true if has first element
            assertTrue(it.next() != null); //Should return first element
            assertTrue(it.hasNext()); //Return true if has second element
            assertTrue(it.next() != null); //Should return second element
            assertFalse(it.hasNext()); //Return false, no third element
            assertTrue(it.next() == null); //Return true, no third element         
        }and I can't figure out a way to pass all of these tests. I have written several variants and none of them works completely, only partially, inconsistently. I just don't know how to write it.
    The SimpleHashSet is declared like this:
    public class SimpleHashSet<E> extends AbstractSet<E> {
        private static final int SIZE = 11;
        LinkedList<E>[] buckets = new LinkedList[SIZE];
    }I appreciate all help and guidance,
    PR.

    Awesome, great answers, very helpful, thanks very much. Careful debugging and testing led me to a working solution. It passes my tests. This is what I have:
        @Override
        public Iterator<E> iterator() {
            final SimpleHashSet<E> here = this;
            Iterator<E> it = new Iterator<E>() {
                private final SimpleHashSet<E> mySet = here;
                private List<LinkedList<E>> bucketList = Arrays.asList(mySet.buckets);
                private Iterator<LinkedList<E>> bucketsIterator = bucketList.iterator();
                private LinkedList<E> currentBucket;
                private Iterator<E> elements;
                    currentBucket = bucketsIterator.next();
                    elements = currentBucket.iterator();  
                @Override
                public boolean hasNext() {
                    while (bucketsIterator.hasNext()) {
                        if (elements.hasNext()) {
                            return true;
                        } else {
                            currentBucket = bucketsIterator.next();
                            elements = currentBucket.iterator();
                    if (elements.hasNext())
                        return true;
                    return false;
                @Override
                public E next() {
                    while (bucketsIterator.hasNext()) {
                        if (elements.hasNext()) {
                              return elements.next();
                        } else {
                            currentBucket = bucketsIterator.next();
                            elements = currentBucket.iterator();
                    if (elements.hasNext())
                        return elements.next();
                    if (!bucketsIterator.hasNext())
                        throw new NoSuchElementException();
                    return null;
            return it;
        }I'm only not sure if it behaves the same as an original HashSet iterator. I doubt. The problem with my implementation is that both hasNext() and next() progress the internal iterators forward, so i.e. calling hasNext() on an empty set will progress the internal iterators to the end, so then adding some elements and calling hasNext() again will return false. I couldn't figure out a way that hasNext() does not progress the iterators, so that only next does that. Both hasNext() and next() are dependent on each other in my example. But it works.
    Thanks,
    PR.

  • Implementing equals() and hashcode

    Hi,
    I need to implement equals() and hashcode() in a class. I only need to use one class variable in the equals() method; String id.
    I'm having difficulties to understand the examples I've seen - can someone please help me out?
    regards, Puzz

    And I know you said you had a hard time understanding some examples, but I'm not sure which examples you've seen. Here is some recommended reading that I think explains this concept well:
    Sun's Java Tutorial: The equals and hashCode Methods
    Josh Bloch: Effective Java
    JavaWorld: Implementing equals and hashCode
    IBM: Defining hashCode() and equals() effectively and correctly
    JavaPractices: Implementing hashCode
    JavaWorld: override hashcode/equals
    ~

  • The type must implement the inherited abstract method???

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.ActiveEvent;
    import java.applet.*;
    public class MoveIt extends Applet implements ActionListener
         private Image cup;
         private Panel keyPad;
         public int yaxis = 15;
         public int xaxis = 15;
         private Button keysArray[];
         public void init()
              cup = getImage(getDocumentBase(), "cup.gif");
              Canvas myCanvas = new Canvas();
              setBackground(Color.blue);
              setLayout(new BorderLayout());
              Button up = new Button("Up");
              Button down = new Button("Down");
              Button right = new Button("Right");
              Button left = new Button("Left");
              Button center = new Button("Center");
              add(myCanvas, BorderLayout.NORTH);
              add(keyPad, BorderLayout.SOUTH);
              keyPad.add(up, BorderLayout.NORTH);
              up.addActionListener(this);
              keyPad.add(down, BorderLayout.SOUTH);
              down.addActionListener(this);
              keyPad.add(right, BorderLayout.EAST);
              right.addActionListener(this);
              keyPad.add(left, BorderLayout.WEST);
              left.addActionListener(this);
              keyPad.add(center, BorderLayout.CENTER);
              center.addActionListener(this);
         public void paint( Graphics g )
              g.drawImage( cup, xaxis, yaxis, this );
         public void ActionPerformed(ActionEvent e)
              String action = e.getActionCommand();
              if(action.equals("Up"))
                   yaxis = yaxis - 15;
              if(action.equals("Down"))
                   yaxis = yaxis + 15;
              if(action.equals("Left"))
                   xaxis = xaxis - 15;
              if(action.equals("Right"))
                   xaxis = xaxis + 15;
              if(action.equals("Center"))
                   xaxis = 125;
                   yaxis = 60;
    }How come there is an error:
    The type MoveIt must implement the inherited abstract method
    ActionListener.actionPerformed(ActionEvent)
    What the hell does that mean?

    A class that implements an interface must define the methods of the interface. Your applet (or the one you borrowed) states at the top that it implements the ActionListener interface. If you go to the API, you'll see that this interface declares a method "actionPerformed", and so this class must have a method that matches the one in the interface. I see that your applet will have some Buttons. You'll need an actionPerformed method if you want the buttons to use your class (this) as their action listener.
    Edit: I see that you already have an "ActionPerformed" method, but note that case matters, and this is not the same as "actionPerformed". Change one letter and you're on your way.
    Edited by: Encephalopathic on Jan 15, 2008 8:44 PM

  • ServerMBean start and kill methods return unserializable objects

    The ServerMBean start and kill methods both return unserializable
    objects which makes them unusable from a JVM other than that on which
    the server runs.
    This is unfortunate, as one would expect these things to be fairly
    standard tasks for a JMX client.
    I noticed in 7.0 they have been deprecated along with stop() - is
    there a known workaround for the time being?
    Thanks,
    Andrew Rosenfeld.

    I can't really answer you final question yet, but I will add what I know at this time, and look into it later next week.
    The JNLPClassLoader extends SecureClassLoader, so as the doc you refer to implys (in it's chapter on SecureClassLoader), the PermissionCollection it grants to code is statically bound at the time a class's defineClass() is called. The JNLPClassLoader's getPermissions() method starts with super.getPermissions, so the current policy permissions are added to those granted by the jnlp client, but it is still unmodifyable after that.
    For local intrenet applications several configuration options have been added in 1.5.0 (J2SE 5.0) that may help.
    You can implement an enterprise wide system configuration that includes system or user level policy files.
    You can also configure pre-accepted certificates so all code signed by your company can be trusted without the users seeing a security warning dialog.
    /Dietz

Maybe you are looking for

  • Will they ever give me an update after 24 hours

    I put my order 24th July, they gave me an estimate date on 12th, Aug for activation. but nothing happened on 12th, Aug. So I phoned BT customer service, they helped to have a check and said there was some issue with Exchange and they would work on it

  • Secure use of JCO

    Whatu2019s SAPu2019s u201Cbest practiceu201D in utilizing JCO?  A hacker only needs to know SAP host, system number, and the program ID. Then he can stand up a JCO server instance and start intercepting outbound calls.   Any suggestions to make it mo

  • Devices drop off my EA6350 network every 1-2 days but internet access is maintained

    Devices on my network disappear every few days. Internet access is maintained for computers but I can't see other devices on the network. Is there something I need to change in my settings? Do DHCP reservations affect this? The situation is very frus

  • Job is skipping PI message processing

    Hi Gurus, I nedd help in our PI message processing. Here is our issue: Everyday there is a batch job in SM37 (a customized program for all 3rd parties that is connected to PI) that retrieves the daily files from the 3rd parties systems and these are

  • Broadband option 3 fup

    I have been on option 3 for a good few months now but have started watching tv from work and it uses a lot of data . Can someone tell me if it is truly unlimeted or is there a fair usage policy cap. Any answers would be much welcomed. Solved! Go to S