Field symbol in iteration expression
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