Interfaces and implementation

My first lecture in "Programming Distributed Components" included this code listing:
import java.util.Date;
import java.util.Comparator;
import java.io.*;
public interface LogMessage
public Date getDate();
public String getMessage();
public String getSource();
public Comparator BY_DATE_DESC = new Comparator()
public int compare(Object o1, Object o2)
LogMessage lhs = (LogMessage) o1;
LogMessage rhs = (LogMessage) o2;
int dateCompare = rhs.getDate().compareTo(lhs.getDate());
if(dateCompare == 0)//in the event that dates are equal sort by message
{                    //note - this is still a descending sort.
dateCompare = rhs.getMessage().compareTo(lhs.getMessage());
return dateCompare;
Call me stupid (please don't) but I was brought up to believe that java interfaces did not contain code implementation. Has the world gone mad or just my University lecturer? Or is it me? If the above code looks correct to you what is it that I am missing in my understanding of interfaces?
Thanks

I've not come across anything like this before. The
interfaces I have seen have tended to be rather simple
affairs consisting of simple contant declarations and
method signatures.They usually are. Your professor is getting fancy on you. Perhaps the point is to make you question what you think you know.
This opens up to me some other questions such as what
limitations are placed on the use of such objects? If
an object is a constant does that mean all its members
are constants? Why no use of "final" in this context -
is it already implicit in interfaces?There are no constants in Java per se. There are finals, which are variables that cannot be assigned once. A final primitve is effectively a constant and a final reference to an immutable Object (like a String) is effectively a constant (for our purposes.) All variables in interfaces are implicitly static and final.

Similar Messages

  • Best practice for Javadoc comments in both an interface and implementation

    For the Spring project I'm writing, I have interfaces with typically 1 implementation class associated with it. This is for various good reasons. So I'm trying to be very thorough with my Javadoc comments, but I realize I'm basically copying them over from interface to implementation class. Shouldn't Javadoc have a setting or be smart enough to grab the comments from my interface if the implementation class doesn't have a comment? Unless of course there is interesting information about the implementation, it's rare the 2 sets of comments would be different.

    Thanks Thomas!! Exactly what I was looking for. Here's the JavaSE 6 version of the page you provided:
    http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html#inheritingcomments

  • Interfaces and implementing them

    public interface foo{
    public int blah();
    public interface foo2{
    public int blah2()
    how would I go around implementing foo and foo2

    I don't think it makes sense to have "inner interfaces". You can implement foo2 as
    public class A implements foo.foo2 {
      public int blah2() { return 2; }
    }or both interfaces (looks funny)
    public class A implements foo, foo.foo2 {
      public int blah() { return 1; }
      public int blah2() { return 2; }
    }

  • Concrete classes implement abstract class and implements the interface

    I have one query..
    In java collection framework, concrete classes extend the abstract classes and implement the interface. What is the reason behind extending the class and implementing the interface when the abstract class actually claims to implement that interface?
    For example :
    Class Vector extends AbstractList and implements List ,....
    But the abstract class AbstractList implements List.. So the class Vector need not explicitly implement interface List.
    So, what is the reason behind this explicit definition...?
    If anybody knows please let me know..
    Thanx
    Rajendra.

    Why do you post this question again? You already asked this once in another thread and it has been extensively debated in that thread: http://forum.java.sun.com/thread.jsp?forum=31&thread=347682

  • Implementing SingleThradModel interface and synchronizing service

    Hi all,
    I came across the one question.
    What is difference between the implementing SingleThradModel interface and synchronizing service method in the Servlet?
    Which one is the better one? and why?
    It seems to be same for me... but still confused?
    Please explain me.
    Thanks,
    Rahul

    No one is better. Just write threadsafe code. E.g. do not declare instance variables which are to be used per request. Just keep in mind that only one instance of the Servlet will be created which lives as long as the webapplication runs and that it will be reused among all requests. Keep request scoped variables inside the method block and you're safe.

  • What is the diffrence between My Runnable Interface and Java Runnable

    Hi folks
    all we know that interfaces in java just a decleration for methods and variables.
    so my Question is why when i create an interface its name is "Runnable" and i declared a method called "run" inside it.then when i implements this interface with any class don't do the thread operation but when i implement the java.lang.Runnable the thread is going fine.
    so what is the diffrence between My Runnable Interface and Java Runnable?
    thnx

    Hi folks
    all we know that interfaces in java just a decleration
    for methods and variables.
    so my Question is why when i create an interface its
    name is "Runnable" and i declared a method called
    "run" inside it.then when i implements this interface
    with any class don't do the thread operation but when
    i implement the java.lang.Runnable the thread is going
    fine.
    so what is the diffrence between My Runnable Interface
    and Java Runnable?
    thnxClasses and interfaces are not identified by just their "name", like Runnable. The actual "name" the compiler uses is java.lang.Runnable. So even if you duplicate the Runnable interface in your own package, it's not the same as far as the compiler is concerned, because it's in a different package.
    Try importing both java.util.* and java.awt.* (which both have a class or interface named List), and then try to compile List myList = new ArrayList();

  • Extending and implementing

    Is there a way to tell the compiler: this variable is of this class and implements that interface.
    Say for instance a Component that implements ActionListener
    extending component with an abstract class that implements ActionListener and then extend this class wouldn't work since then i can'T as well extend button textArea ect.

    if(variable instanceof Component) {
    //do something
    if(variable instanceof ActionListener) {
    //do something else
    if( (variable instanceof Component) &&
    (variable instanceof ActionListener) ) {
    // really do something else
    }

  • HARDWARE interfacing and software routines

    Hello there,
    I am interested in finding out a really basic tutorial/note which will allow me to work with the basic communication protocols like SPI , RS 232, etherner, USB, etc. I am looking for tutorial with BOTH HARDWARE interfacing  and software routines.
    Multiple websites will be ok for me.
    I have searched wikipedia and lot of power point presentations but was not successful in landing up with a COMPLETE tutorial which explains the hardware interfacing connections and software.
    If you guys can suggest an evaluation kit where i can pracice the above interfacing and software routine..... by all means do let me know.
    Looking forward to your reply.

    Technically you can do everything you are talking about for free provided you have the internet tool kit installed (Full Development Suite) and depending on what level of detail you plan on going into.
    If you want to play with RS232 you can start with just taking the existing Labview example, "Basic Serial Write and Read.vi" under Labview Help -> Find Examples.  You can find a serial cable and connect it to your Comm port.  On the other end of the Comm port you can insert a small wire to short pin 2 to pin 3 (TX to RX).  You will then be able to send and recieve data on the same vi.  I would look at wikipedia to learn more:  http://en.wikipedia.org/wiki/RS-232
    If you have the internet tool kit install then you can do all kinds of stuff with just a regular internet connection.  For example any place where you can Telnet you could test using the "Telnet Line Client.vi" provided by Labview.  Again I would start by consulting wikipedia if you have questions:  http://en.wikipedia.org/wiki/Telnet
    If you are trying to do everything down to the hardware level then this is a little more involved.  Again break your post into smaller pieces and repost on the Labview forum and you will have better luck getting detailed responses.
    You should not have to spend much money to play around.  You can build a lot of this stuff yourself or you can purchase very cheep if you shop around.  For example you can implement SPI using a parallel port but you need to know what your target SPI interface will be.  Regards, SS 

  • Need information about interfaces and namespaces in actionscript 3.0

    Hi,
    I need information about actionscript interfaces and
    namespaces, I'm preparing for ACE for Flash CS3 and I need to learn
    about this subjects and I can not find resources or simple examples
    that make these subjects understandable.
    Anybody can help me!
    Thanks a lot.

    Interfaces (cont.)
    Perhaps the most useful feature of interfaces is that you not
    only can define the data type but also method signature of the
    class that implements this interface. In other words, interface can
    define and enforce what methods class MUST implement. This is very
    useful when classes are branching in packages and team of
    developers works on a large application among others.
    The general syntax for an Interface with method signatures is
    written the following way:
    package{
    public interface InterfaceName {
    // here we specify the methods that will heave to be
    implemented
    function method1 (var1:dataType,
    var2:datType,…):returnType;
    function method2 (var1:dataType,
    var2:datType,…):returnType;
    To the previous example:
    package{
    public interface IQualified {
    function method1 ():void;
    function method2 ():int;
    Let’s write a class that implements it.
    If I just write:
    package{
    public class ClassOne extends DisplayObject implements
    IQualified {
    public function ClassOne(){}
    I will get a compilation error that states that I did not
    implement required by the interface methods.
    Now let’s implement only one method:
    package{
    public class ClassOne extends DisplayObject implements
    IQualified {
    private function method1():void{
    return;
    public function ClassOne(){}
    I will get the error again because I implemented only one out
    of two required methods.
    Now let’s implement all of them:
    package{
    public class ClassOne extends DisplayObject implements
    IQualified {
    private function method1():void{
    return;
    private function method2():int{
    return 4;
    public function ClassOne(){}
    Now everything works OK.
    Now let’s screw with return datatypes. I attempt to
    return String instead of void in method1 in ClassOne:
    private function method1():String{
    return “blah”;
    I am getting an error again – Interface requires that
    the method1 returns void.
    Now let’s attempt to pass something into the method1:
    private function method1(obj:MovieClip):void{
    return;
    Oops! An error again. Interface specified that the function
    doesn’t accept any parameters.
    Now rewrite the interface:
    package{
    public interface IQualified {
    function method1 (obj:MovieClip):void;
    function method2 ():int;
    Now compiler stops complaining.
    But, if we revert the class back to:
    private function method1():void{
    return;
    compiler starts complaining again because we don’t pass
    any parameters into the function.
    The point is that interface is sort of a set of rules. In a
    simple language, if it is stated:
    public class ClassOne implements IQualified
    it says: “I, class ClassOne, pledge to abide by all the
    rules that IQualified has established and I will not function
    correctly if I fail to do so in any way. (IMPORTANT) I can do more,
    of course, but NOT LESS.”
    Of course the class that implements an interface can have
    more that number of methods the corresponding interface requires
    – but never less.
    MORE means that in addition to any number of functions it can
    implement as many interfaces as it is desired.
    For instance, I have three interfaces:
    package{
    public interface InterfaceOne {
    function method1 ():void;
    function method2 ():int;
    package{
    public interface InterfaceTwo {
    function method3 ():void;
    package{
    public interface InterfaceThree{
    function method4 ():void;
    If our class promises to implement all three interface it
    must have all four classes in it’s signature:
    package{
    public class ClassOne extends DisplayObject implements
    InterfaceOne, InterfaceTwi, InterfaceThree{
    private function method1():void{return;}
    private function method2():int{return 4;}
    private function method3():void{return;}
    private function method4():void{return;}
    public function ClassOne(){}
    Hope it helps.

  • Create session bean using interfaces, not implementation classes

    Hi,
    I'm using interfaces and session beans for my persistence/data layer in my adf application.
    I've created a data control for my session bean and during creation of this data control, javabean.xml files are created for the different interfaces that are used in my session bean.
    If I create bindings on these methods, interfaces in jspx-documents I will get errors because he can't find the impl-classes that implement these interfaces.
    When using interfaces in your session bean (as return values or parameters) instead of classes you need to manually create javabean.xml files for the implementation classes.
    It's required by the databindings/datacontrol that the implementation-classes are described in a javabean-format as well? Is this a spec we need to adhere to?
    Could someone verify that you need to create javabean.xml-files for as well the interfaces as the classes when you're working with interfaces in your session beans?
    regards,
    Nathalie

    A patch was released by Oracle to be able to work with Interfaces and so it's not required to work with implementation-classes.
    Patch for 5726754(Base bug 5657179)

  • Interfaces and methods with complex object

    In all the examples I have, the methods of an interface use only basic java datatypes (int, Character, ..)
    I want to pass a Vector that represents a list of objects from one of my own classes to an interface method.
    class Myclass ...
    private String p1;
    private int p2;
    myInterfaceMethod(..., Vector list, ...)
    // list is a vector of Myclass objects
    How do I know about Myclass when implementing the interface and how do I access p1 and p2 ?

    You can use any kind of "complex" object in your interface methods, all of them are objects at last.
    The other question seems to be a misunderstanding of interface implementation. When u "implement" an interface in a class, all that JVM does is to check that you actualy have one method (with code inside its body) for each method you defined previously in the interface.
    Think of an interface as a contract signed by a class. It's forced to implement each method definied in you interface. So, as the method is defined inside the class, you can access any data member of the class without doing anything "special". Do u catch it?

  • Separate interfaces and classes in separate packages?

    I am writing an application in the package 'models.geometry'. I am beginning to get a growing number of interfaces with corresponding implementation classes. I therefore consider adding another packages an move all the interfaces to this package and keep the implementation in the original package:
    'models.igeometry' // for the interfaces
    'models.geometry' // for the implementation
    But is this interface/class - package separation good practice?

    First of: Usage of the prefix "I" to identify interfaces is rather rare in the Java world (it's not unheard of, but definitely not the norm). And I've never seen "i<package>" to identify a package containing interfaces, so I wouldn't suggest it.
    The question is: What does the code which uses your packages access? Does it only need the interfaces and a factory? In this case, I'd separate the packages into "models.geometry" and "models.geometry.impl".
    If the classes are first-level API, just as the interfaces (think Link/ArrayList, Map/HashMap), then I'd keep them in the same package or separate them on some other property.

  • Rollout and implementation

    Hi,
    In general or XI perspective, can you explain the difference between rollout and implementation projects.
    Some say that implementation is something where you get involve in all phases of SDLC.
    Some say it as End to End starting from requirement gathering, In XI perspective i believe there would be only implementation projects when compared to general R/3.
    Do Comment on this.

    In my view...
    An implementation would be end-to-end, from requirement gathering to post go-live for a fresh implementation of functionality and applications. In XI terms that would involve creating new interfaces to support the new scenarios.
    A roll-out would be where you are extending existing functionality and scenarios to support more geographic locations, or more business units within the organisation. E.g. you implement SAP HR for the UK based business, then after you have gone live and stabilised the environement you get France-based business to start using it. This may involve extra config and minor developments. Similarly, in XI you will probably have very little to do, unless you need to connect to loacl systems, or develop extra interfaces, or load proper codepages etc.
    Hope this helps?
    Cheers
    Manish

  • Question on figure 3-4 of SNASw Design and Implementation guide

    Hello,
    on figure 3-4 on page 3-7 of the SNASw Design and Implementation guide there is an example code of SNASw port and links for Upstream Hosts.
    There is one port statement and two link statements, one for each host.
    However, assume I have one host with two OSA interfaces, can I use the same coding (two links, one for each OSA), as a redundancy mechanism of the OSAs? How can I choose the primary link?
    Or if I do this configuration I will achieve also load-balancing? (both links active)
    Regards, Apostolos.

    HPR is built on top of APPN with respect to path determination. In APPN the session path is determined by the Topology and Routing Services (TRS) component in the Network Node serving the device originating the session. TRS calculates this path by looking at the characteristics associated with each possible Transmission Group (TG a.k.a. link) that can be used for the session. In the case you are talking about where you have parallel TGs (two or more links) between two nodes, and unless you do some customizing of the TG profiles, they will have equal weight (desireability). This means that over time (and with enough sessions) you would see the load balanced over the two links. If you customize the TG profile (on snaswitch you use the tgp keyword), you can achieve the result of all sessions on a primary link and no sessions on a backup link until the primary link fails. - Ray

  • 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..

Maybe you are looking for