FIELD-SYMBOLS is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details.
FIELD-SYMBOLS
Basic
form
FIELD-SYMBOLS
Additions
1. … STRUCTURE s
DEFAULT wa
2. … TYPE t
3. … TYPE LINE OF t
4. … LIKE s
5. …
LIKE LINE OF s
Effect
This statement declares a symbolic field called
ASSIGN . All operations performed with the field symbol then directly affect the
field assigned to it.
You can only use one of the
additions.
Example
Output aircraft type from the table SFLIGHT using a
field symbol:
FIELD-SYMBOLS
TABLES SFLIGHT.
…
ASSIGN
SFLIGHT-PLANETYPE TO
WRITE
Addition 1
…
STRUCTURE s DEFAULT wa
Effect
Assigns any (internal) field string or
structure to the field symbol from the ABAP/4 Dictionary ( s ). All fields of
the structure can be addressed by name:
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.
Example
Address
components of the flight bookings table SBOOK using a field
symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS
SBOOK
DEFAULT SBOOK_WA.
…
WRITE:
Addition 2
… TYPE t
Addition 3
… TYPE
LINE OF t
Addition 4
… LIKE s
Addition 5
… LIKE LINE OF
s
Effect
You can use additions 2 to 5 to type field symbols in the
same way as FORM parameters (see also Type assignment of subroutine parameters).
ASSIGN performs the same type checks as with USING parameters of FORM s.