Skip to Content
avatar image
Former Member

Can we create a Object for the Interface.

Hi.

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

Give me an example. if possible.

Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Sep 23, 2008 at 08:17 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 23, 2008 at 08:39 AM

    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

    Add comment
    10|10000 characters needed characters exceeded