KEMBAR78
Field Symbols in ABAP Programming | PDF | Data Type | Software Development
0% found this document useful (0 votes)
18 views4 pages

Field Symbols in ABAP Programming

Field Symbols in ABAP are placeholders for data objects that do not reserve memory but point to the content of data objects. There are two types of field symbols: Typed Field Symbols, which have a specified data type, and Generic Field Symbols, which use generic data types for dynamic programming. Field Symbols can replace work areas for faster processing of internal tables, directly referencing rows instead of storing copies.

Uploaded by

Hari Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Field Symbols in ABAP Programming

Field Symbols in ABAP are placeholders for data objects that do not reserve memory but point to the content of data objects. There are two types of field symbols: Typed Field Symbols, which have a specified data type, and Generic Field Symbols, which use generic data types for dynamic programming. Field Symbols can replace work areas for faster processing of internal tables, directly referencing rows instead of storing copies.

Uploaded by

Hari Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

7️⃣

Field Symbols in ABAP


Programming
1. Introduction
Field Symbols are placeholders for the data objects ( Variable, Work Area etc. ).

Field Symbols do not reserve any physical memory space, but they point to the content of
the data objects.

After declaring a field symbol, we can assign the data object to the field symbol.

After successful assignment, whenever we address a field symbol, ultimately we are


addressing the data object that is assigned to that field symbol.

Syntax : FIELD-SYMBOLS <FS>


In the above syntax, FIELD-SYMBOLS = keyword, where fs is the name of the field
symbol.

The name of the field symbol is always enclosed between <>.

2. Types of Field Symbols

Field Symbols in ABAP Programming 1


Mob No :- 6261538504
Field symbols are of two types :-

1. Typed Field Symbol

2. Generic Field Symbol

3. Typed Field Symbol


When we provide the data element like elementary, complex etc. to the field symbol then it
is called as typed field symbol.

IF we specify a type to the field symbol, the system checks the compatibility of the field
symbol and the data object assigned to that field symbol.

Example - FIELD-SYMBOLS : <fs> TYPE i.


In the above syntax, the field symbol is of elementary data type integer(I).

4. Generic Field Symbol


When we provide the generic data types like ANY and ANY TABLE to the field symbol,
then it is called as generic field symbol.

Generic Field symbols are used for dynamic programming.

Example -
1. FIELD-SYMBOLS : <FS_STR> TYPE ANY.

2. FIELD-SYMBOLS : <FT_TAB> TYPE ANY TABLE.

5. Typed Field Symbol Implementation

DATA : lv_name(30) TYPE c VALUE 'Shivam Singh'.

*&--------------------------------------------------------
*&Defining field symbol

Field Symbols in ABAP Programming 2


Mob No :- 6261538504
FIELD-SYMBOLS : <fs_name> TYPE c.

*&-----------------------------------------------------
*&Assigning variable to field symbol.
ASSIGN lv_name TO <fs_name>.
IF <fs_name> IS ASSIGNED.
<fs_name> = 'Amrit Raj'.
WRITE :/ lv_name.
ENDIF.

Output

As soon as we will change the value of field symbol, by default the value of data object will
change.

6. Field Symbol as a Replacement of Work Area


We can replace work area by field symbol while performing internal table operations.

This is because work area stores a copy of the internal table row, whereas field symbol
directly references the internal table row.

Hence, processing of internal table with field symbol is faster than the processing of internal
table with work area.

Requirement :-
We will fetch out the records from the employee table and this time we will use field
symbols to display those records on the output screen.

Implementation :-

Field Symbols in ABAP Programming 3


Mob No :- 6261538504
TYPES : BEGIN OF ty_employee,
emp_id TYPE ZAR_emp_id,
emp_name TYPE ZAR_emp_name,
department TYPE zar_department,
manager TYPE zar_manager,
END OF ty_employee.

DATA : lt_employee TYPE TABLE OF ty_employee,


ls_employee TYPE ty_employee.

FIELD-SYMBOLS : <fs_employee> TYPE ty_employee.

DATA : lv_Emp_id TYPE zar_emp_id.


SELECT-OPTIONS : s_emp_id FOR lv_emp_id.

SELECT emp_id emp_name department manager


FROM zar_emp_tab
INTO TABLE lt_employee
WHERE emp_id IN s_emp_id.

LOOP AT lt_employee ASSIGNING <fs_employee>.


IF <fs_employee> IS ASSIGNED.
WRITE :/ <fs_employee>-emp_id, <fs_employee>-emp_name, <f
ENDIF.
ENDLOOP.

Output

Field Symbols in ABAP Programming 4


Mob No :- 6261538504

You might also like