SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Obsolete Language Elements → Obsolete Declarations → Field Symbols →
FIELD-SYMBOLS - obsolete_typing
Obsolete Syntax
... { } | STRUCTURE struc DEFAULT dobj ...
Extras:
1. ... { }
2. ... STRUCTURE struc DEFAULT dobj
Effect
These additions of the statement FIELD-SYMBOLS produce an obsolete typing of the field symbol and are forbidden in classes.
... { }
Effect
If no explicit type is specified after FIELD-SYMBOLS, the field symbol is
typed implicitly with the fully generic type any. Also, the field symbol
is assigned the predefined constant space when the context is loaded. This
means that the field symbol is not initial directly after it has been declared, and a check using IS ASSIGNED is true.
... STRUCTURE struc DEFAULT dobj
Effect
If the addition STRUCTURE (which is forbidden within classes) is specified for a field symbol instead of typing and struc is a local program structure (a data object, not a data type) or a flat structure from ABAP Dictionary, this structure is cast for the field symbol <fs>. dobj must be used to specify a data object that is assigned to the field symbol as an initial object.
The field symbol inherits the technical attributes of structure struc as if it were completely typed. For a structured data object dobj, the
fragment view
has to match the struc view. In the case of an elementary data object, the
object must be character-like and flat, and struc must be character-like
only. The same applies to assignments of data objects to field symbols typed using STRUCTURE
when using the statement ASSIGN.
Note
Field symbols declared using the addition STRUCTURE are a mixture of typed field symbols and a utility for
casting to structured
data types. The additions TYPE or LIKE of the
statement FIELD-SYMBOLS should be used to type field symbols, while the addition
CASTING of the statement ASSIGN is used for casting.
Example
The first example shows the obsolete usage of the addition STRUCTURE.
DATA wa1 TYPE c LENGTH 512.
FIELD-SYMBOLS <scarr1> STRUCTURE scarr DEFAULT wa1.
<scarr1>-carrid = '...'.
The second example shows the replacement of STRUCTURE with the additions TYPE and CASTING.
DATA wa2 TYPE c LENGTH 512.
FIELD-SYMBOLS <scarr2> TYPE scarr.
ASSIGN wa2 TO <scarr2> CASTING.
<scarr2>-carrid = '...'.
Executable Example
Field Symbols, Cast Structures