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

Static Interface Methods in ABAP

Hello,

I'd like to know what sense it makes to define static methods in an interface.

My understanding is, that an interface can only be used with an instance of a class implementing that interface. So I always need to have an instance and thus, static methods are not needed.

But ABAP-OO (in contrast to Java, for example) allows that, so maybe there is some need for that?

Thanks for your help, best regards,

Timo Wolf.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Feb 01, 2005 at 10:52 AM

    Hi,

    As you know that static methods are not instance- specific. Hence when a class implements an interface, the methods defined as static do not require an instance-specific call. Rather they are called as CLASSNAME=>INTREFACE_NAME~STATIC_METHOD_NAME. You do not need an instance to access them.

    The only purpose of declaring a method as STATIC in interface definition is to create an agreement that a particular method will not depend on an instance to work. When a class implements the interface, calls to this method will be as mentioned above.

    <b>

    As far as the static components of interfaces are concerned, you can only use the interface name to access constants:

    Addressing a constant <const>: <intf>=><const>

    For all other static components of an interface, you can only use object references or the class <class> that implements the interface:

    Addressing a static attribute <attr>: <class>=><intf~attr>

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

    </b>

    Hope this helps.

    Regards

    Message was edited by: Shehryar Khan

    Message was edited by: Shehryar Khan

    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.