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: 

Interfaces in ABAP Objects

Former Member
0 Kudos

some body please tell why this code snippet is giving a syntax error

syntax error:interface component "INTERF~A" doesnot exist

interface interf.

data a type i.

aliases a1 for interf~a.

endinterface.

class abc definition.

public section.

interfaces interf.

private section.

methods use.

endclass.

class abc implementation.

method use.

endmethod.

endclass.

data obj type ref to abc.

start-of-selection.

create object obj.

2 REPLIES 2

Rocky1
Active Participant
0 Kudos

Hi,

Its giving error because aliases cannot be declared within an interface for the component of same interface. You can create aliases for the component of interface a in interface b or in a class. For example the following is valid:

INTERFACE I1.

METHODS method1.

ENDINTERFACE.

INTERFACE I2

METHODS method2

ALIASES m1 for I1~method1.

ENDINTERFACE.

Hope it will help you.

Thanks & Regards

Rocky

Former Member
0 Kudos

Try out with this code and let me know if it works.

interface interf.

data a type i.

endinterface.

    • Here, create a second Interface 'interf_added' & use aliasing ''a1'' for the component 'a' of Interface ' interf' within it**

interface interf_added.

aliases a1 for interf~a.

endinterface.

class abc definition.

public section.

interfaces interf_added.

private section.

methods use.

endclass.

class abc implementation.

method use.

endmethod.

endclass.

data obj type ref to abc.

start-of-selection.

create object obj.