2013 Nov 12 9:30 AM
DATA: l_abc(10) type C.
l_abc = 'xxx'.
DATA dref1 TYPE REF TO data,
GET REFERENCE OF l_abc INTO dref1.
then how can I get the access of the content of 'dref1', namely 'xxx'?
I have tried many forms with 'dref' but didnt work it out.
I know I can assign it to a field-symbol and then use the field symbol.
but this goes for another question, why not use field-symbol directly instead of doing such a complicated thing?
2013 Nov 12 12:04 PM
Hi Ming,
dref is data reference variable.The actual contents of a reference variable ie the value of a reference is not visible in an ABAP program.To access the contents of the data object to which a data reference is pointing, you must dereference it.
ASSIGN dref->* TO <fs> [CASTING ...].
DATA: l_abc(10) type C.
l_abc = 'xxx'.
DATA dref TYPE REF TO char10.
GET REFERENCE OF l_abc INTO dref.
WRITE / dref->*.
DATA: l_abc(10) type C.
l_abc = 'xxx'.
DATA dref1 TYPE REF TO data,
GET REFERENCE OF l_abc INTO dref1.
then how can I get the access of the content of 'dref1', namely 'xxx'?
I have tried many forms with 'dref' but didnt work it out.
I know I can assign it to a field-symbol and then use the field symbol.
but this goes for another question, why not use field-symbol directly instead of doing such a complicated thing?
2013 Nov 12 9:39 AM
OK, I think I found the answer on another website.
It is NOT allowed to get the access of the content of 'dref1' directly(if it refers to a simple data type),
we have to assign it into a FS.
So now who can explain the benefits of doing such a thing instead of using FS directly?
2013 Nov 12 9:55 AM
The field symbol <FS> can have data objects of any time assigned to it. When you assign a data object, the field symbol inherits its technical attributes. The data type of the assigned data object becomes the actual data type of the field symbol
2013 Nov 12 10:32 AM
Use this:
DATA: dref TYPE REF TO data.
FIELD-SYMBOLS: <w_abcd> TYPE ty_abcd.
CREATE DATA dref LIKE <w_abcd>.
ASSIGN dref->* TO <w_abcd>.
Regards
Vivek
2013 Nov 12 11:01 AM
Hi Ming ,
You can actually look into this link for a idea ,
http://www.teamabap.com/2013/01/field-sym-and-data-references/
Regards ,
Shiv
2013 Nov 12 12:04 PM
Hi Ming,
dref is data reference variable.The actual contents of a reference variable ie the value of a reference is not visible in an ABAP program.To access the contents of the data object to which a data reference is pointing, you must dereference it.
ASSIGN dref->* TO <fs> [CASTING ...].
DATA: l_abc(10) type C.
l_abc = 'xxx'.
DATA dref TYPE REF TO char10.
GET REFERENCE OF l_abc INTO dref.
WRITE / dref->*.
2013 Nov 12 12:45 PM
Thanks, this is exactly what I want.
If you want to use dref->* directly, you need TYPE REF TO a specific type.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |