FIELD-SYMBOLS <fs>.
1. ... TYPE
type
2. ...
TYPE REF TO cif
3. ...
TYPE REF TO DATA
4. ...
TYPE LINE OF type
5. ...
LIKE s
6. ...
LIKE LINE OF s
7. ...
TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field
to the field symbol using ASSIGN.
All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
...
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
... TYPE type
... TYPE REF TO cif
... TYPE REF TO DATA
... TYPE LINE OF type
... LIKE s
... LIKE LINE OF s
... TYPE tabkind
You can define the type of the field symbol using additions 2 to 7 (just as you can for
FORM parameters (compare Defining
the Type
of Subroutine Parameters). When you use the ASSIGN
statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Assigns any (internal) field string or structure to the field symbol from
the ABAP Dictionary (s). All fields of the structure can
be addressed by name: <fs>-fieldname. The structured
field symbol points initially to the work area wa specified
after
DEFAULT.
The work area wa
must be at least as long as the structure
s. If s contains
fields of the type I or F, wa should have the structure
s or at least begin in that way, since otherwise alignment problems may occur.
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
...
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Declaring Field Symbols