Application Development and Automation 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: 
Read only

Can we create a Object for the Interface.

Former Member
0 Likes
2,632

Hi.

Can we create a Object for the Interface. How it is possible?

Give me an example. if possible.

Thank you.

Hi.

Can we create a Object for the Interface. How it is possible?

Give me an example. if possible.

Thank you.

2 REPLIES 2
Read only

narin_nandivada3
Active Contributor
0 Likes
1,968

Hi,

No need to create an object for interface and will get an error if try creating it.

Directly specify the interface name and then the method name..

or else.

Data
   w_ref type ref to <interface name>. " No need to instantiate the object

w_ref~<interface method>.

Hope this would help you.

Good luck

Narin

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,968

Hello Krishna

For sure you can create interface instance provided that there is an implementing class around. Example:

DATA: go_msglist   TYPE REF TO if_reca_message_list.

go_msglist = cf_reca_message_list=>create( ).

For a more elaborate example you may have a look at [Message Handling - Finding the Needle in the Haystack |https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack]

Final remark: The previous posting is a bit odd because interface methods never have any implementation.

Regards

Uwe