Annymous data

[pre]
*&———————————————————————*
*& Report ZANNYMOUS_DATA_OBJECT
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT ZANNYMOUS_DATA_OBJECT.

CLASS main DEFINITION.
PUBLIC SECTION.
METHODS get_value
RETURNING VALUE(r_data) TYPE REF TO data.
ENDCLASS.

CLASS main IMPLEMENTATION.
METHOD get_value.
FIELD-SYMBOLS TYPE ANY.
DATA v_fs TYPE char2.

“chung ta tao 1 reference toi data v_fs
CREATE DATA r_data LIKE v_fs.

” di chuyen reference to 1 field symbols
ASSIGN r_data->* TO .

” gan noi dung cua reference thong qua field-symbols
MOVE ‘AB’ TO .
ENDMETHOD.
ENDCLASS.

DATA:
v_char TYPE char2,
v_value TYPE REF TO data,
main TYPE REF TO main.
FIELD-SYMBOLS TYPE ANY.

START-OF-SELECTION.
create OBJECT main.
” phuong thuc tra ve reference cua data vao trong bien v_value
v_value = main->get_value( ).

“chung ta khong the truy cap truc tiep noi dung
“cua reference, ma phai su dung dereferencing
“operator ->* de di chuyen gia tri toi 1 field-symbols
ASSIGN v_value->* TO .

“di chuyen noi dung cua field-symbols toi v_char, va v_char se lam viec voi chung ta
“dung voi gia tri va phuong thuc get_value( ) tra ve.
MOVE TO v_char.

write: / v_char.

[/pre]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s