Field Symbols

Field Symbols

Field Symbols are used to address the fields indirectly. The functionality of the Field Symbols corresponds to the functionality of the pointers in other programming languages.

The declaration of Field Symbols is as shown below,

FIELD-SYMBOLS <fs> Type type

There are four different possibilities to define data type of field symbols

  • Reference to a built-in data type
  • Reference to the ABAP dictionary
  • Reference to a pre-defined type
  • Reference to a generic type

Built-in Type:

Field-Symbols  <fs-char> Type C

ABAP Dictionary:

Field-Symbols  <fs-dict> Type tablename

Predefined Type:

Field-Symbols  <fs-pr> Type ty-pre

Generic Type:

Creating Data Objects dynamically

  1. Field-symbols, data references are declared
  2. Data reference is created with a particular data type
  3. The address of the data reference is assigned to the field symbol

Field-Symbols <fs-table1> Type Standard table

Data: lr-ref Type ref to data

Data l_table_name type tabname.

L_table_name= `Z-Table´.

Create data lr_ref type standard table of l_table_name.

Assign lr_ref-> *To <fs-table1>

SELECT * From <l_table_name> INTO Corresponding fields of Table <fs-table1>

The initial assignment of field symbol to a data object succeeds with the “Assign” command.

Assign Dataobject to <fs-example>

Field Symbols are mainly used to improve the performance during runtime. Data should not be copied to the work area.

Data l_int1 Type i value 1,

Field-Symbols <fs-int> Type i.

Assign l_int1 to <fs-int>

<fs-int> = 2 => which automatically sets l_int1 = 2

Common Address

Note: Field-Symbols must always be assigned to a data object before we proceed with any operations. Otherwise, it gives an error during runtime.