FIELD-SYMBOL

Field Symbol, wenn die Komponenten erst zur Laufzeit bekannt werden.

TYPES: BEGIN OF line,         
 col1 TYPE c,         
 col2 TYPE c,       
 END OF line. 
DATA: wa TYPE line,      
 itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,      
 key(4) TYPE c VALUE 'COL1'. 
FIELD-SYMBOLS <fs> TYPE ANY TABLE. 
ASSIGN itab TO <fs>. 
READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa. 

The internal table itab is assigned to the generic field symbol , after which it is possible to address the table key of the field symbol dynamically. However, the static address

READ TABLE WITH TABLE KEY col1 = ‚X‘ INTO wa.

is not possible syntactically, since the field symbol does not adopt the key of table itab until runtime. In the program, the type specification ANY TABLE only indicates that is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE would not have been possible from a syntax point of view.

Bem.:

FIELD-SYSTEM <fs> type hasehd table of line with unique key col1.

Dann würde

READ TABLE WITH TABLE KEY col1 = ‚X‘ INTO wa.

funktionieren.

REPORT demo_field_symbols_type. 
DATA: BEGIN OF line,         
 col1(1) TYPE c,         
 col2(1) TYPE c VALUE 'X',       
 END OF line. 
FIELD-SYMBOLS <fs> LIKE line. 
ASSIGN line TO <fs>. 
MOVE <fs>-col2 TO <fs>-col1. 

The field symbol is fully typed as a structure, and you can address its components in the program.