0% found this document useful (0 votes)
245 views3 pages

Field Symbols in ABAP

Field symbols in ABAP can provide performance gains over work areas if used correctly. Field symbols are declared to reference table lines or internal tables and allow direct access and modification of data. It is important to check if a field symbol is assigned before use to avoid reference issues.

Uploaded by

Gautam Malhotra
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)
245 views3 pages

Field Symbols in ABAP

Field symbols in ABAP can provide performance gains over work areas if used correctly. Field symbols are declared to reference table lines or internal tables and allow direct access and modification of data. It is important to check if a field symbol is assigned before use to avoid reference issues.

Uploaded by

Gautam Malhotra
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/ 3

ABAP Field Symbols usage

ABAP Field Symbols are very powerful. Usage of Field-Symbols would provide performance
gain, but for that you must use it correctly otherwise you may run into issues.

Field-symbols can provide great performance over using workarea as I have mentioned in my
earlier article Use of Field-symbols vs Work area. I have mentioned many articles using Field-
Symbols but wanted to note down the basics as part of this code snippet.

Declare a Field Symbols

TYPES: tt_mara TYPE STANDARD TABLE OF mara.

DATA: t_mara TYPE tt_mara.

FIELD-SYMBOLS: <lfs_mara> LIKE LINE OF t_mara. " <<

" Field symbol without type

FIELD-SYMBOLS:

<lfs_any_tab> TYPE ANY TABLE,

<lfs_any> TYPE ANY.

APPEND and INSERT using Field Symbols

* Append line

APPEND INITIAL LINE TO t_mara ASSIGNING <lfs_mara>.

<lfs_mara>-matnr = '123456'.

* insert table

INSERT INITIAL LINE INTO t_mara ASSIGNING <lfs_mara> INDEX 2.

<lfs_mara>-matnr = 'ABCDEF'.

Access ITAB rows using Field Symbols

* Read table
READ TABLE t_mara ASSIGNING <lfs_mara>

WITH KEY matnr = '123456'.

IF sy-subrc EQ 0.

WRITE: <lfs_mara>-matnr.

ENDIF.

* Access via Loop

LOOP AT t_mara ASSIGNING <lfs_mara>.

WRITE: <lfs_mara>-matnr.

ENDLOOP.

Modify an entry using Field-Symbols:

* READ and MODIFY

READ TABLE t_mara ASSIGNING <lfs_mara>

WITH KEY matnr = '123456'.

IF sy-subrc EQ 0.

<lfs_mara>-ersda = sy-datum.

ENDIF.

* LOOP and MODIFY

LOOP AT t_mara ASSIGNING <lfs_mara>.

<lfs_mara>-ersda = sy-datum + 1

ENDLOOP.

CHECK field Symbols using IS ASSIGNED

Check if Field Symbol is assigned to a valid reference

* Check if Field-Symbol is assigned

IF <lfs_mara> IS ASSIGNED.
WRITE: 'Assigned'.

ELSE.

WRITE: 'Unassigned'.

ENDIF.

Remove the Reference of the Field Symbols

"remvoe the reference

UNASSIGN <lfs_mara>.

Field-Symbols on SAP Help

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy