Skip to Content
author's profile photo Former Member
Former Member

can anybody explain me what is interface

hi gurus

can anyone explain me what is interface

tahnk you

regards

kals.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 01:16 PM

    Hi Kalyan,

    You should be more specific: An interface can mean a connection between two systems or can also be used in the OO-context.

    Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 01:22 PM

    hi

    Interfaces are independent structures that allow you to enhance the class-specific public points of contact by implementing them in classes.

    Interfaces can be defined globally in the R/3 repository or locally in ABAP program

    Can define exactly same components in Interfaces as in Classes

    Unlike classes, Interfaces do not have instances, instead they are implemented by classes

    Implemented using INTERFACES statement in the declaration part of the class

    INTERFACES statement must be included in the PUBLIC SECTION of the class

    Different classes that implement the same interface can all be addressed in the same way.

    Interface references allow users to address different classes in the same manner.

    Interfaces can also be nested.

    Interfaces are the basis for polymorphism in classes, because they allow a single interface method to behave differently in different classes.

    If an interface is implemented in the class, the interface components are added in the public section of the class.

    A component comp of an interface intf, implemented in a class, becomes a fully-fledged member of that class, with the name intf~comp.

    Classes that implement interfaces must implement all of their methods.

    METHOD intf~meth.

    …

    ENDMETHOD.

    Interfaces allow you to use different classes in a uniform way (polymorphism).

    Interface References

    Creating Interface Reference Variables

    DATA obj TYPE REF TO intf.

    Using this reference variable, you can access any of the components defined in the interface

    Nested Interfaces

    Interface can include one or more interfaces as components, which can contain interfaces themselves.

    Compound Interface : It includes other interface as its component.

    Elementary Interface : It does not include any interface as a component.

    All interface components of a compound interface have the same level

    A component interface exists only once even if it is used once more as a component of another component interface.

    Aliases : It can be used to assign alias names to the components of component interfaces, thus making them visible within the interface definition.

    ALIASES <alias name> FOR intf~comp.

    Where, intf = interface name and comp = Component name

    Accessing Objects using Interface References

    It is also possible to directly generate an object to which the interface reference

    variable points initially. In this case, the TYPE addition of the statement CREATE OBJECT must be used to specify a class that implements the interface. CREATE OBJECT iref TYPE class.

    If the interface intf contains an attribute attr and an instance method meth, you can address them as follows:

    Using the class reference variable:

    Accessing an attribute attr: cref->intf~attr

    Calling a method meth: CALL METHOD cref->intf~meth

    Using the interface reference variable:

    Accessing an attribute attr: iref->attr

    Calling a method meth: CALL METHOD iref->meth

    Accessing Static Components of Interfaces

    Use the name of the interface to access constants within an interface.

    Accessing a constant const: intf=>const.

    To access the other static components of an interface, use an object reference or the class class that is implementing the interface.

    Accessing a static attribute attr: class=>intf~attr.

    Calling a static method meth: CALL METHOD class=>intf~meth.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.