Search This Blog

Thursday, June 2, 2011

Loop at Itab Assigning | Accessing Internal Table using Field Symbols

Records in internal tables in abap can be accessed using the following methods :

1) Loop at itab into work-area.
2) Loop at itab assigning <fs-itab> 

Comparison between the above methods.

The field symbol <fs> points directly to the assigned line in memory. Unlike work areas, in which the contents of the line are only available indirectly using the INTOaddition, field symbols allow you to read and change table entries directly.

When you read from an internal table, there are no overheads for copying the table line to the work area. When you change an internal table with the MODIFY statement, you must first fill a work area with values, and then assign them to the internal table. If you work with field symbols instead, you do not have this overhead. This can improve performance if you have large or complex internal tables. It also makes it easier to process nested internal tables.

If the table is small (a couple hundred records) and you are not going to modify any data in it, then the work area will be faster.

If you need to modify data within the table, then assigning a <FS> will be faster.