Parameterized inheritance and implementation

I'm learning generics, and I'm having a problem getting the following to work
I have a base class with some data/behavior
public abstract Base<E> {
//...Then there is a concrete class that extends Base and implements Map
public Concrete<E extends Object & Map<K,V>> extends Base<E extends Object & Map<K,V>> implements Map<K, V>{
//...I cannot seem to specify that the type for Base must be a Map<K, V>.
I've thought about containing and delegating, but really Concrete IS-A Base and Concrete IS-A Map.
Am I missing something about inheritance and generics?
Any suggestions?

James,
Based on your previous posts I think you understand generics as well as I do, and in some aspects, probably better.
I was trying to capture my thought processes (and that is quite hard since mostly this happens sub-consciously - its quite hard to drag it up into consciousness then document it, but the effort was worthwhile for me and hopefully for others as well).
In this particular case, E is Map<K,V>, but there could be all sorts of relationships between the type variables, the idea is to identify these and back substitute them, slowly getting rid of type variables until you can't get rid of any more. The ones you are left with are the ones that need to be type parameters.
take the other post from yesterday
http://forum.java.sun.com/thread.jsp?thread=554360&forum=316&message=2719355
as another worked example...
from
"And I'm trying to create a special generic container (List) which would only take elements that
implement the Keyable interface above. For example:
public class ListOfKeyables <E extends Keyable> extends AbstractList<E>{..."
and
"Now, besides standard List methods that use type varable 'E' in their definitions, I would also
like to have a special method like this:
   public E getByKey(Object key)   {   ... "
I would start with (ignoring their "E extends Keyable" suggestion, its too premature for that).
public class ListOfKeyables < ???? > extends AbstractList<E> {
    public E getByKey(Object key) { ... }
} but "only take elements that
implement the Keyable interface" suggests replacing E with Keyable<K> thus
public class ListOfKeyables < ???? > extends AbstractList<Keyable<K>> {
    public Keyable<K> getByKey(Object key) { ... }
Note In this case the substitution getting rid of E introduced another type variable (K), thats OK, its still a step toward a solution.
Then the original poster said "But I would like to constrain the 'key' argument in this method to be of type that is specified as a type parameter to the Keyable interface"
So after implementing this requirement we have
public class ListOfKeyables < ???? > extends AbstractList<Keyable<K>> {
    public Keyable<K> getByKey(K key) { ... }
}At this point there is no more substitutions or requirements to fulfill.
So we look through and see what type variables are still unresolved. These (in this case there is only one K), are then the type parameters of the class, and thus we have what I suggested in that post
public class ListOfKeyables <K> extends AbstractList<Keyable<K>> {
    public Keyable<K> getByKey(K key) { ... }
}As a final step, we need to look at the type parameters and decide if they need any constraints (K extends something), These might come from some use of the type parameter ( such as if Keyable constrained its K parameter, we would need to do the same), or from the application requirements. But in this case, there are not any.
At a certain level of abstraction, this process is not a whole lot different to the process you use when working out what parameters a method or constructor needs (and that process also tends to happen below the consciusness threshold).
In really simplistic terms, the answer to both "what parameters do I need" questions is "all the ones you can't get from somewhere else or derive from the ones you already have".
Bruce

Similar Messages

  • Window inheritance problem, implementation question

    This is a multi-part message in MIME format.
    --------------F5AF60803BB8EFA34C8D4288
    Content-Type: multipart/alternative;
    boundary="------------24CDBE5DFBEC0C4205C15C80"
    --------------24CDBE5DFBEC0C4205C15C80
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Hi!
    I have a window inheritance and implementation question. I'm using
    Forte 3.0.J.1.
    I have a super (base) window with a PushButton on it. I want to
    handle the Click event of the button in this super window therefore
    I create an event handler.
    <MyBtn> : PushButton
    I create a sub window inheriting from the previous super window.
    I put some data widgets on it and group all of them (the inherited
    button as well) into a GridField. When I set the mapped type of the grid
    the name of the inherited PushButton widget changes:
    <MainGrid.MyBtn> : PushButton
    When I run the application I get a SystemException with the
    message:
    Attempt to register an event on a NIL object (qqds_C_FieldWidget, 10).
    Traceback:
    SuperWindow.EH at line 0
    SubWindow.Display at line 5
    C++ Method(s)
    UserApp.Run at offset 105
    It is quite understandable that in runtime there is no widget called
    <MyBtn>
    and the event handler of the super class fails.
    But what I don't know : after specifing a mapped type of a GridField why
    changes
    the name of those widgets that haven't got mapped type e.g.: PushButton,
    PictureButton etc.
    How to solve this situation?
    I made a sall example which i send in attachment.
    Thanks for any help and advice in advance...
    Attila Racz Lufthansa Systems
    Hungary
    BUD LSYH
    E-mail: [email protected] .-``'.
    Tel.: (36 1) 431-2910 .` .' Mazsa ter 2-6.
    Fax : (36 1) 431-2977 _.-' '._ H-1107 Budapest,
    Hungary
    --------------24CDBE5DFBEC0C4205C15C80
    Content-Type: text/html; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
    <html>
    <tt>    Hi!</tt><tt></tt>
    <p><tt>I have a window inheritance and implementation question. I'm using</tt>
    <br><tt>Forte 3.0.J.1.</tt><tt></tt>
    <p><tt>I have a super (base) window with a PushButton on it. I want to</tt>
    <br><tt>handle the Click event of the button in this super window therefore</tt>
    <br><tt>I create an event handler.</tt><tt></tt>
    <p><tt>&lt;MyBtn> : PushButton</tt><tt></tt>
    <p><tt>I create a sub window inheriting from the previous super window.</tt>
    <br><tt>I put some data widgets on it and group all of them (the inherited</tt>
    <br><tt>button as well) into a GridField. When I set the mapped type of
    the grid</tt>
    <br><tt>the name of the inherited PushButton widget changes:</tt><tt></tt>
    <p><tt>&lt;MainGrid.MyBtn> : PushButton</tt><tt></tt>
    <p><tt>When I run the application I get a SystemException with the</tt>
    <br><tt>message:</tt><tt></tt>
    <p><tt>Attempt to register an event on a NIL object  (qqds_C_FieldWidget,
    10).</tt>
    <br><tt>      Traceback:</tt>
    <br><tt>          SuperWindow.EH
    at line 0</tt>
    <br><tt>          SubWindow.Display
    at line 5</tt>
    <br><tt>          C++ Method(s)</tt>
    <br><tt>          UserApp.Run
    at offset 105</tt><tt></tt>
    <p><tt>It is quite understandable that in runtime there is no widget called
    &lt;MyBtn></tt>
    <br><tt>and the event handler of the super class fails.</tt><tt></tt>
    <p><tt>But what I don't know : after specifing a mapped type of a GridField
    why changes</tt>
    <br><tt>the name of those widgets that haven't got mapped type e.g.: PushButton,</tt>
    <br><tt>PictureButton etc.</tt><tt></tt>
    <p><tt>How to solve this situation?</tt>
    <br><tt>I made a sall example which i send in attachment.</tt><tt></tt>
    <p><tt>Thanks for any help and advice in advance...</tt><tt></tt>
    <p><tt>---------------------------------------------------------------------------</tt>
    <br><tt> Attila Racz                                    
    Lufthansa Systems Hungary</tt>
    <br><tt>                                                
    BUD LSYH</tt>
    <br><tt>E-mail: [email protected]      
    .-``'.</tt>
    <br><tt>Tel.: (36 1) 431-2910               
    .`   .'     Mazsa ter 2-6.</tt>
    <br><tt>Fax : (36 1) 431-2977           
    _.-'     '._    H-1107 Budapest, Hungary</tt>
    <br><tt>---------------------------------------------------------------------------</tt>
    <br><tt></tt> </html>
    --------------24CDBE5DFBEC0C4205C15C80--
    --------------F5AF60803BB8EFA34C8D4288
    Content-Type: application/x-zip-compressed;
    name="Inh.zip"
    Content-Transfer-Encoding: base64
    Content-Disposition: inline;
    filename="Inh.zip"
    UEsDBBQAAAAIAAdlGicvhmSHbAUAAFITAAAHAAAASW5oLnBleO1YbW/bNhD+bAP+D/yWDGsN
    Uq9WvQxwHQfx4MSGra7oR0qkYq2yZEhys/z73ZGSLdty0A7rMAyloDfy7rkXUndHBfIpTok/
    n8/INF3LPC6nm23yMU6HvW6vG6dhshOyILdxsU34yyLP/pBhOWyM3OV8I5+z/DN03o9WZLGc
    LyZL/xOZFrM4yHn+Qm7I3Wi2mijEt2/Jyh8tfXI3X34cLW/JeDZarcjtBO7LkT+dP6563SjL
    n3kuCFntAlBFZM8kLsiGb7dSDI+GtzJvIQAhk8fbV0W0afJhuZovT+hOodpoGlhj6PBHjz5Q
    3E0fp8cg7YNNbnI78kfE/7SYtANcGm9iVMYejYYJL4p2d5FYT3tBojzbnEx0/0NRcyBMr7vm
    BdnugiQOCdnIcp2JmmPYOjhN43J4yii/yLQka56KROZkcn/904Ekz0DH8qXX7RRrnktxc82T
    JHu+ydI3JPsi8zwWUr0IGfFdUt5kUYTsnTLnacHDMs5Snnw11yYDBbNvkSPioszjYFc2eKKo
    yaQJlT297s82s5nlmIxiY1zouyO9SJqUUdVv4N2gdTPgcCj1LDqgFCAYMHlRFClyC4gjeGDM
    UO+MucijxuumhQTBgEacKgh63oDVQTFnzRPIClfFrFsNwUAlEw4G4sQZp6HNUS2iFrXh7tQj
    GkITVF6AM9j36WYq6mN/2ACFZCFCGIreRlyXo4OspnfwuOQdJUZroeTbIojwbMjWB6prUYvT
    g/2H5gmcVGDzxBEzNvSO4wxqg04ENLyDWnjqSbnnxF4XDjRvAHCGGrGpbQnXswzXcqTqsQDC
    YMeHspUpW+u5ETCNpmfD1TDAV9KmbIBaqBO1ONhso7su2BxKhNCsh8ZogBConOVEsGY9Fyeq
    uQpcxj3mhXhwEyGovkq8OpI5zMMFzs2BYzim6wJxUJFTxRKGwC6hT4aKkTZARA2FWjCT4aut
    kO1I4+NKhdgIi8SSpufpGCZTQVRAHDZD41miOQmMx9mx34il/0Rk/N+EvY7yZxKnkj9JyPzX
    0NVJoUSA56vLPry6GDINt4ogzPwRMpXFP0ImvRgyQzRP6QrB0xIOczxHWq5rwN1SYQLXQ6vF
    qMnAthzbHbgWBDQGsZZ5kmpnhwctVNixB14Ik214ATVNd6/HSThtWy3KnRiQIdKJI2ZsSgt2
    mGDDhWgHBln6rTkjVBnC6oVcLefq+6h8Ze0ZcWIG6lF5rrnAIdQqPc0aH6LuoHkCRUs+Aojj
    lNSaj4yTfBSGDp46FwHEIR01nOfSr85FB0MgHb2ai/ilXAQQ+OBxvHKFHqiUCTklYt7XZCeA
    eC1BUWapfkfovKQMMJRQtxatVie3TnRgAsOKoQDBxVqrfVrj1GQ8Ok9r9X6hbS+w3ymsJsvf
    p+MJmb//bTJu37G8RtLcc9S7opYtS8tQgxO3MjDWyto61uB9mPj389vz4b/fet0qOe/LgX6V
    w3vdADfKvW4hk6g/38pUbVr0TibJsi2K7mxzmQNZUcoc0179TApMdP39RqfzvJYpKXnxub9a
    70oQkxKRIYf8UxUFOJUKelgJHCdZIbVEGNJKDr+DtViUHExVWmPXd5S8rwC+wdP/Pf8drPjX
    PHi8iW6qgOtsr0Kvq5z1y8PL+zL9FRwRh5+1s5T/Fjwv+7Ps6eEp7y925QzqtuurBti7d0ec
    VZnW9G/1sbZ9jM3fQSBwnG22vIyDOInLlxnwJ1ATUqwZq78N/ssWy8TRYjGbjtXPFRxcSqw8
    Qyg8Gz+SOg9QnMb+OpdcqAF/+UH1T1P44KAUbtJW/6Eeqyq0quvjKxxbleCBOH160FMJBave
    ENwcvoo3dcl+U1f02gvaD2d/zf4CUEsBAhQAFAAAAAgAB2UaJy+GZIdsBQAAUhMAAAcAAAAA
    AAAAAQAgALaBAAAAAEluaC5wZXhQSwUGAAAAAAEAAQA1AAAAkQUAAAAA
    --------------F5AF60803BB8EFA34C8D4288--

    import javax.swing.JOptionPane;
    public class Test{
         public static void main(String[] args)
              String newItem = "Item";
              float newSerial = 4234;
              float newCode = 3424;
              int newBase = 1000;
              boolean YesWarranty = true;
              boolean NoWarranty = true;
              Machinery test1 = new Machinery(newItem, newCode, newSerial, newBase, YesWarranty, NoWarranty);
              JOptionPane.showMessageDialog(null, "Item: " + test1.getItem() + " Serial: " + test1.getSerial() + " Code: " + test1.getCode()
              + " Warranty: " + test1.IncludeWarranty() + " No Warranty: " + test1.ExcludeWarranty()+ " Base: " + test1.getPrice());
    }Tested with this and it seems to be ok?
    Changed my final code too because it seemed to always add the 10% whether YesWarranty was true or false, so made it
              if (TrueWarranty==true) //There is a warranty, it returns the base price plus 10%
                   return (base+((base/100)*10));May have posted here too early if it does work, but there is another part so if ive trouble with that il be back :P
    Edited by: dave_the_bear on 16-Nov-2010 07:17
    Changed base to double and used the *0.1 method

  • When to use inheritance and When to use Composition

    java support both inheratiance and composition .I also know "is a" and
    "has a realitionship" but there is always a problem with me to understanding whethere i have to use extends or having a object of a class has a member of othere class.
    and also "A pure OOP must support polimorphisim,inheretiance,encapluction,Abstraction and Composition" correct me if i am wrong
    thank you and have a nice day.

    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • Inheritance and access control - "private protected"

    I'm reopening an old topic, seems to have been last discussed here 2-3 years ago.
    It concerns the concept of restricting access to class members to itself, and its subclasses. This is what "protected" does in C++ and "private protected" did in early versions of the Java language. This feature was removed from Java with a motivation along the lines of not being "simple", and "linear" (in line with the other access modes, each being a true subset of the next). Unfortunately, the article which explained Sun's position on this keyword combination seems to have been removed from the site, so I haven't been able to read its original text.
    But regardless of simplicity of implementation or explaining Java's access modifiers to newbies, I believe it is a fundamental part of OO programming for such an access mode to exist. The arguments for having the standard "private" mode in fact also apply for having a C++-style "protected" mode. (Arguing that classes within a package are related and it therefore doesn't hurt to also give them access to Java's "protected" members, is equally arguing that "private" is unneccessary, which noone of course believes.)
    The whole concept of inheritance and polymorphism and encapsulation builds on the access modes private, protected, and public (in the C++ senses). In Java the "package" concept was added - a nice feature! But I see no justification for it to negate the proper encapsulation of a class and its specializations.

    What effect upon inheritance other than hiding members
    from subclasses is there?
    None. And I cant think of another declaration that prevents members from being inherited but private.
    Of course the onus comes on the programmer with Java's
    definition of "protected" - but
    1) there is rarely a single programmer working within
    a package
    The point was the package is a unit which does not hide from itself. Just like all methods within a class can see each other, all classes within a package can, and all packages within a program can.
    2) it muddies the encapsulation in the design - when
    you see a "protected" method someone else, or yourself
    some time ago - wrote, how do you know if the design
    intention is to have it accessed solely by the class
    and its subclasses, or if it is indeed intended to be
    shared with the whole package? The only way to do
    this today is to always explicitly specify this in the
    comments, which may be lacking, inconsistent, and
    abused (since it isn't enforced).Encapsulation would be implementation hiding. Not method hiding. The only thing you should probably allow out of your package is an interface and a factory anyway.
    I understand where you are coming from, but I really have not had occasion to take issue with it. I can't think of a real codeing situation where this is required. OTOH, I can't think of a coding situation where I need to access a protected method from another class either.

  • A question about inheritance and overwriting

    Hello,
    My question is a bit complicated, so let's first explain the situation with a little pseudo code:
    class A {...}
    class B extends A{...}
    class C extends B {...}
    class D extends C {...}
    class E extends B {...}
    class F {
      ArrayList objects; // contains only objects of classes A to E
      void updateObjects() {
        for(int i = 0; i < objects.size(); i++)
          A object = (A) objects.get(i); // A as superclass
         update(A);
      void update(A object) { ... }
      void update(B object) { ... }
      void update(D object) { ... }
    }My question now:
    For all objects in the objects list the update(? object) method is called. Is it now called with parameter class A each time because the object was casted to A before, or is Java looking for the best fitting routine depending on the objects real class?
    Regards,
    Kai

    Why extends is evil
    Improve your code by replacing concrete base classes with interfaces
    Summary
    Most good designers avoid implementation inheritance (the extends relationship) like the plague. As much as 80 percent of your code should be written entirely in terms of interfaces, not concrete base classes. The Gang of Four Design Patterns book, in fact, is largely about how to replace implementation inheritance with interface inheritance. This article describes why designers have such odd beliefs. (2,300 words; August 1, 2003)
    By Allen Holub
    http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
    Reveal the magic behind subtype polymorphism
    Behold polymorphism from a type-oriented point of view
    http://www.javaworld.com/javaworld/jw-04-2001/jw-0413-polymorph_p.html
    Summary
    Java developers all too often associate the term polymorphism with an object's ability to magically execute correct method behavior at appropriate points in a program. That behavior is usually associated with overriding inherited class method implementations. However, a careful examination of polymorphism demystifies the magic and reveals that polymorphic behavior is best understood in terms of type, rather than as dependent on overriding implementation inheritance. That understanding allows developers to fully take advantage of polymorphism. (3,600 words) By Wm. Paul Rogers
    multiple inheritance and interfaces
    http://www.javaworld.com/javaqa/2002-07/02-qa-0719-multinheritance.html
    http://java.sun.com/docs/books/tutorial/java/interpack/interfaceDef.html
    http://www.artima.com/intv/abcs.html
    http://www.artima.com/designtechniques/interfaces.html
    http://www.javaworld.com/javaqa/2001-03/02-qa-0323-diamond_p.html
    http://csis.pace.edu/~bergin/patterns/multipleinheritance.html
    http://www.cs.rice.edu/~cork/teachjava/2002/notes/current/node48.html
    http://www.cyberdyne-object-sys.com/oofaq2/DynInh.htm
    http://www.gotw.ca/gotw/037.htm
    http://www.javajunkies.org/index.pl?lastnode_id=2826&node_id=2842
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=001588
    http://pbl.cc.gatech.edu/cs170/75
    Downcasting and run-time
    http://www.codeguru.com/java/tij/tij0083.shtml
    type identification
    Since you lose the specific type information via an upcast (moving up the inheritance hierarchy), it makes sense that to retrieve the type information ? that is, to move back down the inheritance hierarchy ? you use a downcast. However, you know an upcast is always safe; the base class cannot have a bigger interface than the derived class, therefore every message you send through the base class interface is guaranteed to be accepted. But with a downcast, you don?t really know that a shape (for example) is actually a circle. It could instead be a triangle or square or some other type.
    To solve this problem there must be some way to guarantee that a downcast is correct, so you won?t accidentally cast to the wrong type and then send a message that the object can?t accept. This would be quite unsafe.
    In some languages (like C++) you must perform a special operation in order to get a type-safe downcast, but in Java every cast is checked! So even though it looks like you?re just performing an ordinary parenthesized cast, at run time this cast is checked to ensure that it is in fact the type you think it is. If it isn?t, you get a ClassCastException. This act of checking types at run time is called run-time type identification (RTTI). The following example demonstrates the behavior of RTTI:
    //: RTTI.java
    // Downcasting & Run-Time Type
    // Identification (RTTI)
    import java.util.*;
    class Useful {
    public void f() {}
    public void g() {}
    class MoreUseful extends Useful {
    public void f() {}
    public void g() {}
    public void u() {}
    public void v() {}
    public void w() {}
    public class RTTI {
    public static void main(String[] args) {
    Useful[] x = {
    new Useful(),
    new MoreUseful()
    x[0].f();
    x[1].g();
    // Compile-time: method not found in Useful:
    //! x[1].u();
    ((MoreUseful)x[1]).u(); // Downcast/RTTI
    ((MoreUseful)x[0]).u(); // Exception thrown
    } ///:~
    As in the diagram, MoreUseful extends the interface of Useful. But since it?s inherited, it can also be upcast to a Useful. You can see this happening in the initialization of the array x in main( ). Since both objects in the array are of class Useful, you can send the f( ) and g( ) methods to both, and if you try to call u( ) (which exists only in MoreUseful) you?ll get a compile-time error message.
    If you want to access the extended interface of a MoreUseful object, you can try to downcast. If it?s the correct type, it will be successful. Otherwise, you?ll get a ClassCastException. You don?t need to write any special code for this exception, since it indicates a programmer error that could happen anywhere in a program.
    There?s more to RTTI than a simple cast. For example, there?s a way to see what type you?re dealing with before you try to downcast it. All of Chapter 11 is devoted to the study of different aspects of Java run-time type identification.
    One common principle used to determine when inheritence is being applied correctly is the Liskov Substitution Principle (LSP). This states that an instance of a subclass should be substitutible for an instance of the base class in all circumstances. If not, then it is generally inappropriate to use inheritence - or at least not without properly re-distributing responsibilities across your classes.
    Another common mistake with inheritence are definitions like Employee and Customer as subclasses of People (or whatever). In these cases, it is generally better to employ the Party-Roll pattern where a Person and an Organization or types of Party and a party can be associated with other entities via separate Role classes of which Employee and Customer are two examples.

  • Private inheritance and dynamic cast issue

    Hello. I am hitting a problem combining private inheritance and dynamic casting, using Sun Studio 12 (Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25):
    I have three related classes. Let's call them:
    Handle: The basic Handle class.
    DspHandle. Handle implementation, able to add itself to a Receiver.
    IODriver. Implemented in terms of DspHandle, It is the actually instantiated object.
    Consider the following code. Sorry, but I've tried my best trying to minimize it:
    #include <iostream>
    using namespace std;
    class Handle {
    public:
    virtual ~Handle() {};
    class Receiver {
    public:
    void add(Handle &a);
    class DspHandle : public Handle {
    public:
    virtual ~DspHandle() {};
    void run(Receiver &recv);
    class IODriver : private DspHandle {
    public:
    void start(Receiver &recv) {
    DspHandle::run(recv);
    void DspHandle::run(Receiver &recv) {
    cout << "Calling Receiver::add(" << typeid(this).name() << ")" << endl;
    recv.add(*this);
    void Receiver::add(Handle &a) {
    cout << "Called Receiver::add(" << typeid(&a).name() << ")" << endl;
    DspHandle d = dynamic_cast<DspHandle>(&a);
    cout << "a= " << &a << ", d=" << d << endl;
    int main(int argc, char *argv[]) {
    Receiver recv;
    IODriver c;
    c.start(recv);
    Compiling and running this code with Sun Studio 12:
    CC -o test test.cc
    ./test
    Calling Receiver::add(DspHandle*)
    Called Receiver::add(Handle*)
    a= ffbffd54, d=0
    The dynamic cast in Receiver::add, trying to downcast Handle to DspHandle, fails.
    This same code works, for example with GNU g++ 4.1.3:
    Calling Receiver::add(P9DspHandle)
    Called Receiver::add(P6Handle)
    a= 0xbfe9c898, d=0xbfe9c898
    What is the reason of the dynamic_cast being rejected. Since the pointer is actually a DspHandle* , even when it is part of a private class, shouldn't it be downcastable to DspHandle? I think that perhaps the pointer should be rejected by Receiver::add(Handle &a) as it could be seen as a IODriver, that can't be converted to its private base. But since it's accepted, shouldn't the dynamic_cast work?
    Changing the inheritance of IODriver to public instead of private avoids the error, but it's not an option in my design.
    So, questions: Why is it failing? Any workarround?
    Best wishes.
    Manuel.

    Thanks for your fast answer.
    But could you please provide a deeper answer? I would like to know where do you think the problem is. Shouldn't the reference be accepted by Receiver:add, since it can only be seen as a Handle using its private base, or should the dynamic_cast work?
    Aren't we actually trying to cast to a private base? However, casting to private bases directly uses to be rejected in compile time. Should the *this pointer passed from the DspHandle class to Receiver be considered a pure DspHandle or a IODriver?
    Thanks a lot.

  • How to find and implement badi's

    hello can any one tell me how to find badi's for a transaction and implement them if any one can show with example will be helpful if any of standard transaction for sd ,
    regards
    afzal

    Hi,
    Just copy and paste this code in editor and execute it.
    Then give your Transaction coe it will displays all user exits Regrading your T.Code.
    *&  Enter the transaction code that you want to search through in order
    *&  to find which Standard SAP User Exits exists.
    *& Tables
    TABLES : tstc,     "SAP Transaction Codes
             tadir,    "Directory of Repository Objects
             modsapt,  "SAP Enhancements - Short Texts
             modact,   "Modifications
             trdir,    "System table TRDIR
             tfdir,    "Function Module
             enlfdir,  "Additional Attributes for Function Modules
             tstct.    "Transaction Code Texts
    *& Variables
    DATA : jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
    DATA : field1(30).
    DATA : v_devclass LIKE tadir-devclass.
    *& Selection Screen Parameters
    SELECTION-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE text-001.
    SELECTION-SCREEN SKIP.
    PARAMETERS : p_tcode LIKE tstc-tcode OBLIGATORY.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN END OF BLOCK a01.
    *& Start of main program
    START-OF-SELECTION.
    * Validate Transaction Code
      SELECT SINGLE * FROM tstc
        WHERE tcode EQ p_tcode.
    * Find Repository Objects for transaction code
      IF sy-subrc EQ 0.
        SELECT SINGLE * FROM tadir
           WHERE pgmid    = 'R3TR'
             AND object   = 'PROG'
             AND obj_name = tstc-pgmna.
        MOVE : tadir-devclass TO v_devclass.
        IF sy-subrc NE 0.
          SELECT SINGLE * FROM trdir
             WHERE name = tstc-pgmna.
          IF trdir-subc EQ 'F'.
            SELECT SINGLE * FROM tfdir
              WHERE pname = tstc-pgmna.
            SELECT SINGLE * FROM enlfdir
              WHERE funcname = tfdir-funcname.
            SELECT SINGLE * FROM tadir
              WHERE pgmid    = 'R3TR'
                AND object   = 'FUGR'
                AND obj_name = enlfdir-area.
            MOVE : tadir-devclass TO v_devclass.
          ENDIF.
        ENDIF.
    * Find SAP Modifactions
        SELECT * FROM tadir
          INTO TABLE jtab
          WHERE pgmid    = 'R3TR'
            AND object   = 'SMOD'
            AND devclass = v_devclass.
        SELECT SINGLE * FROM tstct
          WHERE sprsl EQ sy-langu
            AND tcode EQ p_tcode.
        FORMAT COLOR COL_POSITIVE INTENSIFIED OFF.
        WRITE:/(19) 'Transaction Code - ',
        20(20) p_tcode,
        45(50) tstct-ttext.
        SKIP.
        IF NOT jtab[] IS INITIAL.
          WRITE:/(95) sy-uline.
          FORMAT COLOR COL_HEADING INTENSIFIED ON.
          WRITE:/1 sy-vline,
          2 'Exit Name',
          21 sy-vline ,
          22 'Description',
          95 sy-vline.
          WRITE:/(95) sy-uline.
          LOOP AT jtab.
            SELECT SINGLE * FROM modsapt
            WHERE sprsl = sy-langu AND
            name = jtab-obj_name.
            FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
            WRITE:/1 sy-vline,
            2 jtab-obj_name HOTSPOT ON,
            21 sy-vline ,
            22 modsapt-modtext,
            95 sy-vline.
          ENDLOOP.
          WRITE:/(95) sy-uline.
          DESCRIBE TABLE jtab.
          SKIP.
          FORMAT COLOR COL_TOTAL INTENSIFIED ON.
          WRITE:/ 'No of Exits:' , sy-tfill.
        ELSE.
          FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
          WRITE:/(95) 'No User Exit exists'.
        ENDIF.
      ELSE.
        FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
        WRITE:/(95) 'Transaction Code Does Not Exist'.
      ENDIF.
    * Take the user to SMOD for the Exit that was selected.
    AT LINE-SELECTION.
      GET CURSOR FIELD field1.
      CHECK field1(4) EQ 'JTAB'.
      SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
      CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
    Thanks,
    Reward If Helpful.

  • Inheriting and the "super" keyword

    I found a case where "super" is not working as I understand it should...
    Can someone explain me the underlying theory that makes JAVA behave this way??
    public class Base {
         public void method1() {
              System.out.println("method1 from \"Base\" class. About to call method2.");
              method2();
         public void method2() {
              System.out.println("method2 from \"Base\" class. About to call method3.");
              method3();
         public void method3() {
              System.out.println("method3 from \"Base\" class.");
    public class Extension extends Base {
         @Override
         public void method1(){
              System.out.println("method1 from \"Extension\" class. About to call super.method2.");
              super.method2();          
         @Override
         public void method2(){
              System.out.println("method2 from \"Extension\" class. About to call method3.");
              method3();          
         @Override
         public void method3(){
              System.out.println("method3 from \"Extension\" class.");                    
    public class Main {
         public static void main(String args[]) {
              System.out.println("In \"The Java Programming Language,\n" +
                        "Fourth Edition By Ken Arnold, James Gosling, David Holmes\"\n"+
                        "chapter: 3.3: \"Inheriting and Redefining Members\""+
                        " says:");
              System.out.println("Using super is the only case in which the type of\n" +
                        "the reference governs selection of the method implementation\n" +
                        "to be used. An invocation of super.method always uses the\n" +
                        "implementation of method the superclass defines (or\n" +
                        "inherits). It does not use any overriding implementation of\n" +
                        "that method further down the class hierarchy.\n");
              System.out.println("But by running this code, i get:");
              System.out.println("------------------------------------------");          
              Extension ext = new Extension();
              ext.method1();          
              System.out.println("------------------------------------------");
              System.out.println("\nWHY??? I was expecting:\n"+
                        "method1 from \"Extension\" class. About to call super.method2.\n" +
                        "method2 from \"Base\" class. About to call method3.\n" +
                        "method3 from \"Base\" class.");          
    THANKS!!

    IgnacioKriche wrote:
    But I used "super", so this means to use the methods of the super class and I understand that a method called within another, is part of this last one. this is:
    if inside method 'x', method 'y' is called, then 'y' is part of 'x' . Agree? And therefore since I am using super I'm saying use 'x' method from super class since 'y' is part of 'x' then super applies for 'y' as well so what is method from the extended class doing here? It's like we have a mix between the 'x' from super and 'y' from the extended. Something like super only applies for the first level not at a deeper level (a method called from another)No. Just because the base class method2() invokes method3() does NOT mean it will always invoke base's version of method3. If it did that, then polymorphism would definitely be broken.
    You explicitly invoked super.method2(), so that told the compiler to explicitly use the base class version of that method. But then method2 in the base class invokes method3(). That ends up invoking the overridden version in the subclass, by design, because afterall the actual object whose methods are being executed is a subclass instance. If it didn't do that, then polymorphism would be broken for everyone else.
    If you think you need the behavior you are looking for, you are just designing it wrong in the first place.

  • Inheritance and casting

    Hi,
    I defined interfaces as follows:
    interface A {
    string name ();
    interface B : A {
    string b_method ();
    interface C : A {
    string c_method ();
    interface D {
    A create_object(in long type);
    I've generated java code, and implemented interfaces B, C and D. The interface D is implemented so that when someone calls create_object() method with parameter type=0, it returns an interface B object, and otherwise it returns an interface C object.
    My server application creates an object that implements interface D, and registers it with the nameserver .
    My client application gets the interface D object, and calls its create_object() method with various parameters, and gets its return object that is either the object instance of interface B or C.
    My problem is that I can't discover is this an object of interface B or C. When I check the class type, it always returns the interface A class, and it can't be casted to B or C.
    Has anyone had the same problem ???
    I would appreciate any help or tip!
    Thanks,
    Sasa.

    My client application gets the interface D object, and
    calls its create_object() method with various
    parameters, and gets its return object that is either
    the object instance of interface B or C.Not exactly.
    The client gets a proxy (of type A) to a server-side object, which itself is of type B or C.
    All the client ORB library knows is that the proxy is of type A, since that's what interface D declares, so what else could he return you?
    My problem is that I can't discover is this an object
    of interface B or C.
    org.omg.CORBA.Object.is_a(String );
    When I check the class type, it always returns the interface A class,You mean, when you check with instanceof operator.
    and it can't be casted to B or C.No it can't : it must be narrowed: your IDL compiler must have generated BHelper and CHelper classes, wich contain method narrow().
    This method returns the stub object it is passed if it fulfills the condition, or return a new stub object of the appropriate type.
    Try:A aRef = dObject.create();
    if (aRef.is_a("yourModule::B")
    B bRef = BHelper.narrow(aRef);
    }You already know this construct since you have already narrow()ed the untyped reference you got from the naming service, haven't you?
    N.B.: I don't remeber off-hand the syntax for the String passed to is_a(), but it is the "scoped name" for the interface, that is, it must include the modules hierarchy.

  • Badi creation and implementation

    HI all ,
    I want inforamtion on BADIs.
    How to search for BADI and also creating and implementing the badi .
    Regards
    SAntosh .

    There are two steps in User Exit creation.
    1} Identify the User Exit suitable for the requirement and that is available in the system:
    Code SE18 is used to Identify the BADI available.
    Look for the string 'CL_EXITHANDLER' in the standard program. This is a class which has a method 'GET_INSTANCE' which is used to trigger BADI's from the Standard Program. The interface parameter for this static method 'EXIT_NAME' is used to pass the BADI to the method.
    Open Standard Program and do a global search 'CL_EXITHANDLER'.
    SE18 > give the BADI name found through above search.
    CUSTOMER_ADD_DATA > which has a method SAVE_DATA.
    2} Implement the User Exit identified through above process.
    T.Code SE19 is used to Implement BADI.
    SE19 > give the implementation name > Give the Definition name as CUSTOMER_ADD_DATA and the Short Text.
    Check this blogs 2 find a BADI:
    How to find if we have a BADI in Transaction VB02
    Re: BADI for screen enhancement in MM01  transaction
    Re: BADI and User exits
    How To Define a New BAdI Within the Enhancement Framework (Some Basics About the BAdI,BAdI Commands in ABAP,
    When to Use a BAdI?)
    /people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series
    How to implement a BAdI And How to Use a Filter
    /people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework
    Introducing Business Add-Ins
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f3202186-0601-0010-6591-b832b1a0d0de
    How to implement BAdi in Enhancement Framework
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d0456c54-0901-0010-f0b3-cd765fb99702
    Business Add-Ins
    http://help.sap.com/saphelp_47x200/helpdata/en/ee/a1d548892b11d295d60000e82de14a/frameset.htm
    BAdI: Customer-Defined Functions in the Formula Builder
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    Difference Between BADI and User Exits
    http://www.sap-img.com/abap/difference-between-badi-and-user-exits.htm
    To Use BADI - Business Add In you need to Understand ABAP OO Interface Concept
    http://www.sap-img.com/abap/business-add-in-you-need-to-understand-abap-oo-interface-concept.htm
    You can check the links for Step by Step Badi Implemntation
    (very helpful self learning docs).
    BADI Step by Step Implementation.
    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
    http://help.sap.com/saphelp_nw04/helpdata/en/04/f3683c05ea4464e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/e6/63ee7f486cc143a560799d8803ce29/content.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/srm/badi-general+information&
    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
    The specified item was not found.
    http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
    http://support.sas.com/rnd/papers/sugi30/SAP.ppt
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
    http://members.aol.com/_ht_a/skarkada/sap/
    http://www.ct-software.com/reportpool_frame.htm
    http://www.saphelp.com/SAP_Technical.htm
    http://www.kabai.com/abaps/q.htm
    http://www.guidancetech.com/people/holland/sap/abap/
    http://www.planetsap.com/download_abap_programs.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
    http://www.allsaplinks.com/badi.html
    /people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-serieshttps:///people/alwin.vandeput2/blog/2006/04/13/how-to-search-for-badis-trace-it
    /people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework /people/thomas.weiss/blog/2006/05/03/source-code-enhancements--part-5-of-the-series-on-the-new-enhancement-framework
    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
    http://www.esnips.com/doc/3b7bbc09-c095-45a0-9e89-91f2f86ee8e9/BADI-Introduction.ppt
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/40921dd7-d5cf-2910-1894-bb62316afbd1
    http://help.sap.com/saphelp_erp2005/helpdata/en/73/7e7941601b1d09e10000000a155106/frameset.htm
    http://support.sas.com/rnd/papers/sugi30/SAP.ppt
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
    http://members.aol.com/_ht_a/skarkada/sap/
    http://www.ct-software.com/reportpool_frame.htm
    http://www.saphelp.com/SAP_Technical.htm
    http://www.kabai.com/abaps/q.htm
    http://www.guidancetech.com/people/holland/sap/abap/
    http://www.planetsap.com/download_abap_programs.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/1975cc43b111d1896f0000e8322d00/content.htm
    /people/thomas.weiss/blog/2006/04/03/how-to-define-a-new-badi-within-the-enhancement-framework--part-3-of-the-series
    /people/thomas.weiss/blog/2006/04/18/how-to-implement-a-badi-and-how-to-use-a-filter--part-4-of-the-series-on-the-new-enhancement-framework
    http://esnips.com/doc/e06e4171-29df-462f-b857-54fac19a9d8e/ppt-on-badis.ppt
    http://esnips.com/doc/43a58f51-5d92-4213-913a-de05e9faac0d/Business-Addin.doc
    http://esnips.com/doc/10016c34-55a7-4b13-8f5f-bf720422d265/BADIs.pdf
    http://esnips.com/doc/1e10392e-64d8-4181-b2a5-5f04d8f87839/badi.doc
    http://esnips.com/doc/365d4c4d-9fcb-4189-85fd-866b7bf25257/customer-exits--badi.zip
    http://esnips.com/doc/3b7bbc09-c095-45a0-9e89-91f2f86ee8e9/BADI-Introduction.ppt
    http://help.sap.com//saphelp_470/helpdata/EN/eb/3e7cee940e11d295df0000e82de14a/frameset.htm
    Difference Between BADI and User Exits
    http://www.sap-img.com/abap/difference-between-badi-and-user-exits.htm
    Business Add-Ins
    Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They can be inserted into the SAP System to accommodate user requirements too specific to be included in the standard delivery. Since specific industries often require special functions, SAP allows you to predefine these points in your software.
    As with customer exits (SMOD/CMOD Page 40), two different views are available:
    • In the definition view, an application programmer predefines exit points in a source that allow specific industry sectors, partners, and customers to attach additional software to standard SAP source code without having to modify the original object.
    • In the implementation view, the users of Business Add-Ins can customize the logic they need or use a standard logic if one is available.
    In contrast to customer exits, Business Add-Ins no longer assume a two-system infrastructure (SAP and customers), but instead allow for multiple levels of software development (by SAP, partners, and customers, and as country versions, industry solutions, and the like). Definitions and implementations of Business Add-Ins can be created at each level within such a system infrastructure.
    SAP guarantees the upward compatibility of all Business Add-In interfaces. Release upgrades do not affect enhancement calls from within the standard software nor do they affect the validity of call interfaces. You do not have to register Business Add-Ins in SSCR.
    The Business Add-In enhancement technique differentiates between enhancements that can only be implemented once and enhancements that can be used actively by any number of customers at the same time.
    In addition, Business Add-Ins can be defined according to filter values. This allows you to control add-in implementation and make it dependent on specific criteria (on a specific Country value, for example). All ABAP sources, screens, GUIs, and table interfaces created using this enhancement technique are defined in a manner that allows customers to include their own enhancements in the standard.
    A single Business Add-In contains all of the interfaces necessary to implement a specific task. In Release 4.6A, program and menu enhancements can be made with Business Add-Ins. The actual program code is enhanced using ABAP Objects. In order to better understand the programming techniques behind the Business Add-In enhancement concept, SAP recommends reading the section on ABAP Objects
    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.
    REPORT Z_BADI_TEST.
    test call Badi from standard abap. (Only from rel 6.40 and above)
    do the following
    1) define the Badi (SE18). For Abap call test uncheck multiple use
    and filter boxes
    2) Implement the badi (SE19). Add any methods here in the implemntation
    3) activate
    4) define the standard class exithandler to the abap. This class is the "Badi caller
    5) define an exit variable referring to your Badi Implementation interface
    this interface will normally be something like ZIF_EX***************
    You will see this in SE18/SE19.
    6) Instantiate your instance of the badi (method call get_instance)
    7) Now call any method(s) in the Badi.
    class cl_exithandler definition load. "Declaration
    data exit type ref to zif_ex__jimbotest. "Interface reference
    data yes type c.
    data: v_knvv type knvv. "Used in Fmod call in Badi methods
    start-of-selection.
    yes = ' '.
    selection-screen begin of block b1.
    parameters: r1 radiobutton group rad1,
    r2 radiobutton group rad1,
    r3 radiobutton group rad1.
    selection-screen end of block b1.
    parameters: p_kunnr type knvv-kunnr.
    select single * into v_knvv
    from knvv
    where kunnr eq p_kunnr.
    export v_knvv to memory id 'CUST6A'. "Save customer data for the function module
    call method cl_exithandler=>get_instance "Factory method call
    exporting "Method
    exit_name = 'Z_JIMBOTEST' "Name of your BADI
    null_instance_accepted = yes
    changing instance = exit.
    if not exit is initial.
    break-point 1.
    if r1 = 'X'.
    call method exit->dispord . "Add-In call
    changing testparm1 = word.
    endif.
    if r2 = 'X'.
    call method exit->dispfakt.
    endif.
    if r3 = 'X'.
    call method exit->dispmat.
    endif.
    In the badi methods
    1)
    method ZIF_EX__JIMBOTEST~DISPORD.
    CALL FUNCTION 'Z_DISPLAY_CUST'.
    endmethod.
    2)
    method ZIF_EX__JIMBOTEST~DISPFAKT.
    CALL FUNCTION 'Z_DISPLAY_FAKT'.
    endmethod
    3)
    method ZIF_EX__JIMBOTEST~DISPMAT.
    CALL FUNCTION 'Z_DISPLAY_CUST'.
    endmethod.
    Copy via SE 41 the status SALV_STANDARD from standard SAP program SALV_DEMO_METADATA into the main program where you've created the 3 function modules below (SAP______TOP)
    Global Data for the three function modules I'm calling
    FUNCTION-POOL Z_BADI_KNVV. "MESSAGE-ID ..
    include <color>.
    include <icon>.
    include <symbol>.
    tables: zknvv.
    data: v_zzkvgr6 TYPE KNVV-ZZKVGR6.
    data: choice1 type c.
    data: choice2 type c.
    data: choice3 type c.
    data: choice4 Type c.
    data: ok-code(5) type c.
    data: answer type string.
    data: value1 type SPOP-VARVALUE1.
    data: answer1 type string.
    tables: vbak, vbap, vakpa, vbrk, vrkpa.
    data: lr_functions type ref to cl_salv_functions_list.
    constants: gc_true type sap_bool value 'X',
    gc_false type sap_bool value space.
    add for colour displays
    data: ls_color type lvc_s_colo.
    DATA : LV_SALV_COLUMNS_TABLE TYPE REF TO CL_SALV_COLUMNS_TABLE.
    data: lr_columns type ref to cl_salv_columns_table,
    lr_column type ref to cl_salv_column_table.
    Data:
    gr_table TYPE REF TO cl_salv_table.
    data: z_datum type sy-datum.
    data: v_knvv type knvv.
    data : begin of s_vbak,
    vkorg type vakpa-vkorg,
    vkgrp type vakpa-vkgrp,
    vtweg type vakpa-vtweg,
    spart type vakpa-spart,
    auart type vakpa-auart,
    vbeln type vakpa-vbeln,
    bstnk type vakpa-bstnk,
    audat type vakpa-audat,
    netwr type vbak-netwr,
    end of s_vbak.
    data : begin of s_vbrk,
    vbeln type vrkpa-vbeln,
    vkorg type vrkpa-vkorg,
    fkart type vrkpa-fkart,
    fkdat type vrkpa-fkdat,
    netwr type vbrk-netwr,
    end of s_vbrk.
    data: begin of s_vbap,
    matnr type vbap-matnr,
    arktx type vbap-arktx,
    netwr type vbap-netwr,
    kwmeng type vbap-kwmeng,
    end of s_vbap.
    data: t_vbap like table of s_vbap.
    data: t_vbak
    like table of s_vbak.
    data: t_vbrk
    like table of s_vbrk.
    data: s_name type tabname.
    data: gr_selections type ref to cl_salv_selections.
    data: gr_events type ref to cl_salv_events_table.
    Source code of the function modules.
    Function modules
    FUNCTION Z_DISPLAY_CUST.
    ""Lokale interface:
    s_name = 'S_VBAK'.
    orders in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
    select avkorg aaudat avkgrp avtweg aspart aauart abstnk avbeln b~netwr
    into corresponding fields of table t_vbak
    up to 100 rows
    from ( vakpa as a
    inner join vbak as b
    on avbeln eq bvbeln )
    where a~kunde eq v_knvv-kunnr
    and a~parvw eq 'AG'
    and a~vkorg eq 'EN01'
    and a~trvog eq '0'
    and a~audat gt z_datum.
    sort t_vbak by audat descending.
    *data: gt_hyperlink type standard table of g_type_s_hyperlink.
    Instead of if_salv_c_bool_sap=>false, you can pass the
    value if_salv_c_bool_sap=>true to this method to
    see your ALV as a list.
    display data in Grid / List
    TRY.
    CALL METHOD cl_salv_table=>factory
    EXPORTING
    list_display = if_salv_c_bool_sap=>false
    IMPORTING
    r_salv_table = gr_table
    CHANGING
    t_table = t_vbak.
    CATCH cx_salv_msg.
    ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    ls_color-col = col_negative.
    ls_color-int = 0.
    ls_color-inv = 0.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'VBELN' ).
    ls_color-col = col_negative.
    ls_color-int = 1.
    ls_color-inv = 1.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
    gr_table->display( ).
    ENDFUNCTION.
    FUNCTION Z_DISPLAY_FAKT.
    ""Lokale interface:
    s_name = 'S_VBRK'.
    invoices in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
    select avbeln afkart avkorg afkdat
    b~netwr
    into corresponding fields of table t_vbrk
    up to 100 rows
    from ( vrkpa as a
    inner join vbrk as b
    on avbeln eq bvbeln )
    where a~kunde eq v_knvv-kunnr
    and a~parvw eq 'RG'
    and a~vkorg eq 'EN01'
    and a~vbtyp eq 'M'
    and a~fkdat gt z_datum.
    sort t_vbrk by fkdat descending.
    *data: gt_hyperlink type standard table of g_type_s_hyperlink.
    Instead of if_salv_c_bool_sap=>false, you can pass the
    value if_salv_c_bool_sap=>true to this method to
    see your ALV as a list.
    display data in Grid / List
    TRY.
    CALL METHOD cl_salv_table=>factory
    EXPORTING
    list_display = if_salv_c_bool_sap=>false
    IMPORTING
    r_salv_table = gr_table
    CHANGING
    t_table = t_vbrk.
    CATCH cx_salv_msg.
    ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    ls_color-col = col_negative.
    ls_color-int = 0.
    ls_color-inv = 0.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'VBELN' ).
    ls_color-col = col_negative.
    ls_color-int = 1.
    ls_color-inv = 1.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
    gr_table->display( ).
    ENDFUNCTION.
    FUNCTION Z_DISPLAY_MATERIAL.
    ""Lokale interface:
    s_name = 'S_VBAP'.
    invoicesrs in last 6 months
    z_datum = sy-datum - 180.
    import v_knvv from memory id 'CUST6A'.
    get data
    select avbeln bmatnr barktx bnetwr b~kwmeng
    into corresponding fields of table t_vbap
    up to 100 rows
    from ( vakpa as a
    inner join vbap as b
    on avbeln eq bvbeln )
    where a~kunde eq v_knvv-kunnr
    and a~parvw eq 'AG'
    and a~vkorg eq 'EN01'
    and a~trvog eq '0'
    and a~audat gt z_datum.
    TRY.
    CALL METHOD cl_salv_table=>factory
    EXPORTING
    list_display = if_salv_c_bool_sap=>false
    IMPORTING
    r_salv_table = gr_table
    CHANGING
    t_table = t_vbap.
    CATCH cx_salv_msg.
    ENDTRY.
    try.
    LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    ls_color-col = col_negative.
    ls_color-int = 0.
    ls_color-inv = 0.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'ARKTX' ).
    ls_color-col = col_negative.
    ls_color-int = 1.
    ls_color-inv = 1.
    lr_column->set_color( ls_color ).
    catch cx_salv_not_found.
    endtry.
    try.
    *LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).
    lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).
    lr_column->set_short_text( 'Short' ).
    lr_column->set_medium_text( 'Medium' ).
    lr_column->set_long_text( 'Net Value' ).
    *lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'URL' ).
    catch cx_salv_not_found.
    endtry.
    gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'
    report = sy-repid
    set_functions = gr_table->c_functions_all ).
    this statement actually does the display.
    gr_table->display( ).
    ENDFUNCTION.
    http://www.****************/Tutorials/ExitsBADIs/VL02/page1.htm
    Reward points..

  • Extends and implements

    "extends" => inheritance?
    and "implements" => interface?
    or the opposite?
    and what is the difference between an
    abstract class and interface?
    Thanks in advance
    Jack

    EXTENDS
    Yes, "extends" means inheritance.
    E.g.:
    public class Chihuahua extends Dog {
    }So, from the moment you use "extends" we can say that Chihuahua IS-A Dog.
    IMPLEMENTS
    We use "implements" keyword when a class must implement one or more interfaces.
    E.g.:
    public class Chihuahua extends Dog implements SmallDog, NiceDog{
    }Interfaces are a way to simulate multiple inheritance in Java language.
    Now we also can say that a Chihuahua IS-A Dog, IS-A SmallDog and IS-A NiceDog. Yes, interfaces also causes IS-A relationships.
    ABSTRACT CLASSES x INTERFACES
    Well, some book authors says that interfaces are a more "pure version" of a abstract class. If you don't know yet, all methods of a interface are abstract, that is: the class that implements an interface MUST (with no exceptions) implements (override) all his methods. Is also important to know that all methods in a interface has a header only (no implementation), for instance:
    public interface SmallDog {
    public abstract void walkFast( );
    public abstract void hiddenBelowTheDesk( );
    }But why all methods of an interface must not be implemented? Simply because they are abstract.
    An abstract class can contain OR NOT abstract methods. In mention of the abstract methods the behavior of a class that inherits from a abstract class is the same. Look this example:
    Dog.java
    public abstract class Dog{
       private String raceName;
       public abstract void bark();
       public abstract void run();
       public String getRaceName(){
          return this.raceName;
    }You can see that we have two abstract methods: bark and run. It means that if a class extends from Dog it MUST override the methods bark and run methods. getRaceName is a method, but it isn't an abstract abstract method.
    Now let's see the Chihuahua class again:
    public class Chihuahua extends Dog{
    private BigEye leftEye;
    private BigEye rightEye;
    private BigEar leftEar;
    private BigEar rightEar;
    public void bark(){
    public void run(){
    INTERFACES INHERITS FROM OTHER INTERFACES
    Yes, it can sound crazy, but it is possible in Java. An interface can inherits from other interfaces. It ins't hard to understand. Based on the two interfaces SmallDog and NiceDog we will see how an interface can inherits from another one:
    public interface CompleteCoolDog extends SmallDog, Nicedog{
    }The interface CompleteCoolDog contains all methods from SmallDog and Nicedog, but is not obbligatory to implement them because an interface can not implement methods, only declare them. And who must implement them? The first concrete class that implements CompleteCoolDog interface.
    You can see very nice informations about interfaces and abstract classes in the books of Kathy Sierra and Bert Bates (Study guides for SCJP).
    I hope I helped you a little. Some doubt please, mail me.
    See you =)

  • What is single inheritance, multiple inheritance, and describe Java's notio

    What is single inheritance, multiple inheritance, and describe Java's notion of an interface?
    Can you give me example or reference link? thx

    Single inheritance is getting features like data and methods (functions) from a so called parent class. multiple inheritance is the same but you derive features from multiple parent classes (not supported by java). Interfaces are a way around this because you can inherit multiple interfaces. Inheriting from interfaces is like a promise to implement certain methods that these interfaces define but doesn't implement themselves.
    check around java.sun.com in the tutorials section, you can probably find a text that describes object oriented program and how it is implemented in java.

  • Difference between inheritance and abstract class

    difference between inheritance and abstract class

    See this thread:
    http://forum.java.sun.com/thread.jspa?forumID=24&threadID=663657
    And before Post New Topic, just search in this forums. All most will get answers.

  • Problem with inheritance and outputting values in toString.

    Hey guys, i'm having a major problem with inheritances.
    What i'm trying to do with my program is to create objects in my demo class. Values are passed to several other objects that each do their own calculations of grades and results and then outputs the result in my toString. I followed step by step the instructions in my book on how to setup the inheritance and such. I can only output everything that was created in my superclass, any other thing that was created in an object that belongs to a subclass does not display in the output at all.
    Even if I change or create new instance variables, I can't figure out for the life of myself how to output the other values.
    Because there's so much code to be splitting on the forums, I zipped my whole project in a RAR. I'll link it here
    http://www.4shared.com/file/ZleBitzP/Assign7.html
    The file to run the program is CourseGradesDemo class, everything else is either a subclass or superclass to some part of the program. After you run CourseGradesDemo, you will see the output, and understand what displays and what stays at 0.0 value. If anyone can help me out with this it would be greatly appreciated
    Thanks in advance.

    Basshunter36 wrote:
    Hey guys, i'm having a major problem with inheritances.
    What i'm trying to do with my program is to create objects in my demo class. Values are passed to several other objects that each do their own calculations of grades and results and then outputs the result in my toString. I followed step by step the instructions in my book on how to setup the inheritance and such. I can only output everything that was created in my superclass, any other thing that was created in an object that belongs to a subclass does not display in the output at all.
    Even if I change or create new instance variables, I can't figure out for the life of myself how to output the other values.No idea what you're talking about. Provide an [url http://sscce.org]SSCCE.
    Because there's so much code to be splitting on the forums, I zipped my whole project in a RAR. I'll link it here
    http://www.4shared.com/file/ZleBitzP/Assign7.html
    Not gonna happen. Provide an [url http://sscce.org]SSCCE. And don't say you can't. You definitely can. You may have to spend an hour building a new program from scratch and getting it to reproduce the problem, but if you can't or won't do that, you'll find few people here willing to bother with it.

  • Production and Implementation

    Hello Gurus, 
                          I want the details like....In production support what are the our usual works(roles), and what we have to do. 
                          If we are getting tickets, in which manner we have to respond for those tickets.
                          What are the exact daily works in a production support  project. And what are the exact daily works in a implementation  project.
                          What are the t-codes we have to be perfect in support and implementation.
    Please help me
    Thanks and Regards
    Kumar.

    Hi,
    It may vary in different projects.
    I can just give you a couple of general roles.
    Migration project
    • Designing mapping documents in order to check the need of creation in BW.
    • Developing various objects like Cubes, ODS, Info Sources, InfoObjects etc.
    • Designing Transfer Rules and update rules including start routines, update routines and Transfer routines as per the requirement.
    • Scheduling Info Packages to carry out the data loading process. Involved in data loading from SAP R/3 to Source layer ODSs into BW. Loaded data using Data mart, as the Business layer and Report layer ODSs get loaded from source layer ODSs using data mart functionality of BW.
    • Involve in the backfilling of historical data from present sys to SAP BW .
    • Developing the Master/Transactional data process chains considering the dependency among the BW objects and automated the triggering and monitoring of the same on daily, weekly and monthly basis.
    • Transportation of various BW components.
    • Performing unit testing and data validation of newly developed and enhanced objects in Quality BW system in terms of providing an efficient solution.
    • Responsible for overseeing the Quality procedures related to the project.
    • Responsible to deliver (Transport into Prod) the object as per the scheduled deadlines; with accuracy of deliverables by considering the quality norms.
    • Involving in the Client/Onsite communication for any client side clarifications, for assignment of work, for discussing on project status related issues, etc.
    Support project
    Data Load Monitoring:
    1.Carried out data load on a daily, weekly and monthly basis using Process chains from both SAP Source systems as well as Non-SAP Source systems such as Informatica.
    2.Resolving Data load error such as Invalid characters, Time period conversion, Currency conversion, Duplicate records, etc
    3.Ensuring the availability of the updated data in the datatarget on time.
    4.Spooling out data through Infospoke from SAP BW to systems like Trillium, Ariba (Reporting Tool)
    Ticket Resolution:
    1.Process chain modification: Working on “Optimizing Process chain” by creating new process chain considering the load dependencies.
    2.Reloading of R/3 data from different clusters – Reconciliation issues
    3.Enhancements as per Business requirement.
    Additional responsibilities:
    •Preparing design documents from the Business Requirement docs and identified the relevant data targets for satisfying the customer requirements.
    •Creation of Operational manual: BW Run & Maintain Support.
    •Process Chain Detail Documentation (Sequencing & Dependency within Local Chains).
    •Monitoring checklist Document (From Process Chain Perspective)
    •BW Doc checklist preparation
    •Table space activity with basis team.
    •Data load analysis taking into account the CPU utilization.
    •Applying Support packs and performing ORT.
    Most projects have different number of cubes with varying volume of data. You cant generalize this.
    hope this helps,
    Refer
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/08f1b622-0c01-0010-618c-cb41e12c72be
    Roles & Responsibilities for Junior & Senior consultants(Technical)
    Thanks,
    JituK

Maybe you are looking for

  • Tempro v3.3.3 fails to install on Windows 7 64bit

    Hi, When I try to install Tempro 3.3.3 on Windows 7 64bit it stops after the third step, ends the installation and gives the error: "The installation has ended due to an error" and then the installer exits. Running as admin and/or in 'compatibility m

  • Centro will not Sync with Palm Desktop

    I have removed all Palm references from laptop as suggested in: Community Help Forums : Hardware & Software : Software : Re: Syncs fine -- missing all data in Desktop App with no luck. ( http://forums.palm.com/palm/board/message?board.id=software&mes

  • Target Unreachable, 'FirstName' returned null

    hi when i try to navigate to next page using a button am geting this error Target Unreachable, 'FirstName' returned null,am in jdeveloper 11.1.1.6.0 <SkinFactoryImpl> <getSkin> Cannot find a skin that matches family portal and version v1.1. We will u

  • Can't see the bottom of my notification center with IOS7 on iPhone 5

    Can't see the bottom of my notification center with IOS7 on iPhone 5.

  • Live Chat

    When I went to cancel last month I had to wait 30 minutes to connect to an online chat advisor. (After several attempts)When I DONT log in and click live Chat I get connected in a few seconds (I did actually time it!)Or when I click to upgrade when I