Google Search - Blog...........

ABAP - Use Of Field Symbols In Class Definition - OOPS Concept.

REPORT YSUB_ASSIGN_FS.

FIELD-SYMBOLS : TYPE ANY .

class c1 definition .
public section .
* Instance attribute : inum declared below
data : inum type i value 5 .
* static attribute onum declared below
class-data : onum type i value 10 .
endclass.

class c1 implementation.
endclass.

start-of-selection.
data : oref1 type ref to c1 .
create object oref1.
* Assigning instance attribute to field symbol
assign oref1->inum to .
write:/5 .
* Assigning static attribute to field symbol
assign oref1->onum to .
write:/5 .
assign c1=>onum to .
write:/5 .


Output 5
10
10

No comments:

Post a Comment