Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
jack_graus2
Active Contributor
In table iteration expression (like the FOR expression) one can decide to either use a work area or field symbol.
... FOR wa|<fs> IN itab [INDEX INTO idx] [cond] [let_exp]  ...

The ABAP help does indicate: For each read line, the result is either assigned to a local work area wa1 or to a field symbol <fs>.

In my own developments I prefer to use reference variables over field symbols. In a table iteration expression only field symbol or work area can be used. Because of performance reason I prefer to use field symbols here. But not completely sure there is a difference in performance as the expression does get processed internally. I double check by a small test program: Using field symbol within a table iteration expression does have a performance improvement.
DATA:
lt_mara TYPE mara_tt,
lt_matnr TYPE table_matnr,
lv_timestamp_start TYPE timestampl,
lv_timestamp_end TYPE timestampl,
lv_timestamp TYPE timestampl.

SELECT * FROM mara INTO TABLE lt_mara.

GET TIME STAMP FIELD lv_timestamp_start.
DO 1000 TIMES.
lt_matnr = VALUE table_matnr( FOR ls_mara IN lt_mara ( ls_mara-matnr ) ).
ENDDO.
GET TIME STAMP FIELD lv_timestamp_end.
lv_timestamp = lv_timestamp_end - lv_timestamp_start.
WRITE / `Workarea: ` && lv_timestamp.

GET TIME STAMP FIELD lv_timestamp_start.
DO 1000 TIMES.
lt_matnr = VALUE table_matnr( FOR <ls_mara> IN lt_mara ( <ls_mara>-matnr ) ).
ENDDO.
GET TIME STAMP FIELD lv_timestamp_end.
lv_timestamp = lv_timestamp_end - lv_timestamp_start.
WRITE / `Field symbol: ` && lv_timestamp.

Test

Workarea: 1.6138080
Field symbol: 0.5876100
4 Comments
Sandra_Rossi
Active Contributor
Thanks. I could run the tests on my system, but I would trust you if you could show some data about the performance gain 😉
wjanes
Explorer
Ohh thanks. Nice to know that field symbols have a performance boost. 🙂
DenisGaland
Participant
0 Kudos
I didn't know we could use field symbols there, thanks for the tip 🙂
sh4il3sh
Participant
0 Kudos
replacing wa in my for loops with field symbols henceforth!