2019 Mar 28 4:38 PM
hi all greetings.
i came a across a line of code in ABAP.
<code>DATA: lr_intf TYPE REF TO lif_test,
lr_mine TYPE REF TO lcl_myclass.
<code>CREATE OBJECT lr_intf TYPE lcl_myclass.<br>
here lif_test is an i nterface.
My question is that how exactly object is getting created by TYPE keyword in here using the lcl_myclass.
2019 Apr 01 10:26 AM
I will try to answer your question using how memory is allocated.
So when you write following code-
CLASS c1 DEFINITION. ... ENDCLASS.
DATA oref TYPE REF TO c1.
CREATE OBJECT oref. So in above code we are creating reference to variable oref for class c1 and then we are allocating the memory.
CLASS c1 DEFINITION.
....
ENDCLASS.
DATA oref TYPE REF TO object.
CREATE OBJECT oref TYPE c1.
And in above code we are creating reference to variable object and then we are defining class and allocating the memory.
Hope this will help you.
For more queries you can refer
hi all greetings.
i came a across a line of code in ABAP.
<code>DATA: lr_intf TYPE REF TO lif_test,
lr_mine TYPE REF TO lcl_myclass.
<code>CREATE OBJECT lr_intf TYPE lcl_myclass.<br>
here lif_test is an i nterface.
My question is that how exactly object is getting created by TYPE keyword in here using the lcl_myclass.
2019 Mar 29 2:34 AM
i dont really understand what do you want to know with this question but you could press F1 on the CREATE OBJECT to read how it work.
2019 Mar 29 4:12 AM
Even I don't understand whether you are asking how "create object type" syntax is working or how it is creating object for an interface.
If it is an second doubt, then we can't create an object for an interface unless it is implemented in the class. If you check your lcl_myclass, it must implemented the interface lif_test.
2019 Apr 01 10:26 AM
I will try to answer your question using how memory is allocated.
So when you write following code-
CLASS c1 DEFINITION. ... ENDCLASS.
DATA oref TYPE REF TO c1.
CREATE OBJECT oref. So in above code we are creating reference to variable oref for class c1 and then we are allocating the memory.
CLASS c1 DEFINITION.
....
ENDCLASS.
DATA oref TYPE REF TO object.
CREATE OBJECT oref TYPE c1.
And in above code we are creating reference to variable object and then we are defining class and allocating the memory.
Hope this will help you.
For more queries you can refer
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |