Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Class/Interface/Methods

Former Member
0 Kudos

Hi All,

I'm trying to understand the concept behind abap class/interface/methods.

1. Is it mandatory to have an interface in every class?

2. Once a class is created is it right to define methods as static and public and use them without reference to the interface?

Any help appreciated.

Meghna

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi meghna,

interfaces in ABAP Objects play the same role as classes. Just like classes, interfaces are object types that reside in the namespace of all types. While a class describes all aspects of a class, an interface only describes a partial aspect

The syntax for declaring a local interface is:

INTERFACE intf.

DATA ...

CLASS-DATA ...

METHODS ...

CLASS-METHODS ...

...

ENDINTERFACE.

Basically, the declaration of an interface corresponds to the declaration part of a class, where instead of CLASSu2014ENDCLASS, you simply use INTERFACEu2014ENDINTERFACE. Interfaces can contain exactly the same components as classes. Unlike classes, however, interfaces don't need to be divided into different visibility sections because interface components are always integrated in the public visibility section of classes.

i dont want to confuse you .

please go to the below link to know more about... interface and classes.

[http://help.sap.com/saphelp_nw04/helpdata/en/ec/d9ab291b0b11d295400000e8353423/frameset.htm]

3 REPLIES 3

former_member242255
Active Contributor
0 Kudos

Just search in SDN..you will have lot of threads..

1.it is not mandatory to have an interface in every class.

2.defining the methiods and attributes under different visibilty sections is purely opur requirement basis.

Former Member
0 Kudos

hi meghna,

interfaces in ABAP Objects play the same role as classes. Just like classes, interfaces are object types that reside in the namespace of all types. While a class describes all aspects of a class, an interface only describes a partial aspect

The syntax for declaring a local interface is:

INTERFACE intf.

DATA ...

CLASS-DATA ...

METHODS ...

CLASS-METHODS ...

...

ENDINTERFACE.

Basically, the declaration of an interface corresponds to the declaration part of a class, where instead of CLASSu2014ENDCLASS, you simply use INTERFACEu2014ENDINTERFACE. Interfaces can contain exactly the same components as classes. Unlike classes, however, interfaces don't need to be divided into different visibility sections because interface components are always integrated in the public visibility section of classes.

i dont want to confuse you .

please go to the below link to know more about... interface and classes.

[http://help.sap.com/saphelp_nw04/helpdata/en/ec/d9ab291b0b11d295400000e8353423/frameset.htm]

0 Kudos

Thanks for explaining.

Appreciate your help.

Meghna