SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
Syntax Revisions for Field Symbols
Cannot Use Field Symbols As Class Components
In the declaration part of the class, the following statement causes an error message::
FIELD-SYMBOLS ...
Correct syntax:
DATA ... TYPE REF TO ...
or
ALIASES ...
Cause:
The only components allowed in classes are attributes, methods, and events. Field symbols are symbolic names for other fields. They work by means of
value semantics. Their
role as pointers is now performed in ABAP Objects by reference variables. Their role as symbolic names has now been replaced by aliases.
No field symbols without type assignment
Error message in ABAP Objects if the following syntax is used:
FIELD-SYMBOLS <fs>.
Correct syntax:
FIELD-SYMBOLS <fs> TYPE ANY.
Reason:
Like method interface parameters, field symbols must always have explicit type assignments.
No obsolete castings withASSIGN
Error message in ABAP Objects if the following syntax is used:
ASSIGN f TO <fs> TYPE ... [DECIMALS ...].
Correct syntax:
ASSIGN f TO <fs> CASTING TYPE|LIKE ...
Reason:
The TYPE and DECIMALS additions have been replaced by the addition CASTING [TYPE|LIKE].
Unlike the TYPE addition, CASTING supports any data type.
No Obsolete Casting inFIELD-SYMBOLS
In ABAP Objects, the following statement causes an error message:
FIELD-SYMBOLS <fs> STRUCTURE struc DEFAULT f.
Correct syntax:
FIELD-SYMBOLS <fs> TYPE|LIKE struc.
ASSIGN f TO <fs> CASTING.
Reason:
Field symbols defined with the STRUCTURE addition are a mixture of field symbols whose type is defined and a tool for
casting on data types defined in the ABAP Dictionary or locally in the program. The
types of field symbols are defined
with the TYPE addition of the FIELD-SYMBOLS statement
and the CASTING addition of the ASSIGN statement can be used for the casting.
No local copies usingASSIGN
Error message in ABAP Objects if the following syntax is used:
ASSIGN LOCAL COPY OF INITIAL f TO <fs>.
ASSIGN LOCAL COPY OF f TO <fs>.
Correct syntax:
DATA dref TYPE REF TO data.
CREATE DATA dref LIKE f.
ASSIGN dref->* TO <fs>.
DATA dref TYPE REF TO data.
CREATE DATA dref LIKE f.
ASSIGN dref->* TO <fs>.
<fs> = f.
Reason:
Due to the introduction of the general data references concept, the addition
LOCAL COPY of the statement ASSIGN is obsolete. The value of f can be copied using the assigment <fs> = f after ASSIGN.
No search limitations with dynamic ASSIGN
Error message in ABAP Objects in the following case:
ASSIGN TABLE FIELD (<f>) TO <fs>.
Correct syntax:
ASSIGN (<f>) TO <fs>.
Cause:
Table work areas are not supported in classes.