Ansicht
Dokumentation
ABENABAP_OBJECTS_DIFF_FIELD_SYMBOL - ABAP OBJECTS DIFF FIELD SYMBOL
CL_GUI_FRONTEND_SERVICES - Frontend Services CL_GUI_FRONTEND_SERVICES - Frontend ServicesThis documentation is copyright by SAP AG.
Syntax Revisions for Field Symbols
Cannot Use Field Symbols As Class Components
-
You cannot declare field symbols as components of classes in the declaration part of the class definition. However, you can create local field symbols within methods.
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
-
In ABAP Objects the addition TYPE in the statement FIELD-SYMBOLS is mandatory.
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
-
In ABAP Objects you are not allowed to use the additions TYPE and DECIMALS for assigning data objects to field symbols using ASSIGN.
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 STRUCTURE addition is not allowed in the FIELD-SYMBOLS statement.
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
-
In ABAP Objects it is not possible to use field symbols in procedures to work with copies of other data.
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
-
The search limited to table work areas of the main program in connection with the dynamic ASSIGN statement is no longer used in ABAP Objects.
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.
BAL_S_LOG - Application Log: Log header data General Data in Customer Master
This documentation is copyright by SAP AG.
Length: 5327 Date: 20240418 Time: 010848 sap01-206 ( 67 ms )