Interface reference and component access in ABAP Objects
Page 1 of 1
Interface reference and component access in ABAP Objects
As we know that before creation of any object it must have a reference to a class, similarly an interface can also have a reference. But we know interface cannot be instantiated so why do we need a reference for it?? The interface reference is used from a totally different point of view, an interface reference is used to access the interface components that has been implemented differently in different class. We will elaborate this in the next article. An interface reference can be created similar to object reference.
DATA: interface_ref TYPE REF TO my_interface.
To create an object of the class <class>, you must first have declared a reference variable <cref> with reference to the class. If the class <class> implements an interface <intf>, you can use the following assignment between the class reference variable <cref> and an interface reference <iref> to make the interface reference in <iref> point to the same object as the class reference in <cref>:
<iref> = <cref>
If the interface <intf> contains an instance attribute <attr> and an instance method <meth>, you can address the interface components as follows:
Using the class reference variable <cref>:
• To access an attribute <attr>: <cref>-><intf~attr>
• To call a method <meth>: CALL METHOD <cref>-><intf~meth>
Using the interface reference variable <iref>:
• To access an attribute <attr>: < iref>-><attr>
• To call a method <meth>: CALL METHOD <iref>-><meth>
Uma_ABAP- Posts : 56
Join date : 2012-03-31
Similar topics
» Member access and inheritance in ABAP Objects
» Creating Interface in ABAP Objects with example
» Component visibility in ABAP Objects
» Introduction to interface in ABAP objects
» Polymorphism using interface in ABAP Objects
» Creating Interface in ABAP Objects with example
» Component visibility in ABAP Objects
» Introduction to interface in ABAP objects
» Polymorphism using interface in ABAP Objects
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Aug 20, 2012 4:37 pm by Admin
» Difference between Type and Like
Thu Jun 07, 2012 2:40 pm by Admin
» How to handle table control fields in Module Pool program?
Wed May 09, 2012 2:41 am by govind
» Three tables inner join in SAP
Thu May 03, 2012 4:47 pm by Uma_ABAP
» Creating table type in ABAP
Sat Apr 28, 2012 9:03 pm by Uma_ABAP
» Creating user defined types and structures in ABAP
Sat Apr 28, 2012 8:55 pm by Uma_ABAP
» Creating Dynamic Internal Table and Dynamic Field catalog in SAP-ABAP
Fri Apr 27, 2012 11:00 am by Admin
» Copy Custom PF-Status from Standard program to Custom Program in ALV
Thu Apr 26, 2012 9:52 pm by Uma_ABAP
» Calculate/find number of working days between two dates in SAP
Tue Apr 24, 2012 2:06 pm by Uma_ABAP