|
Programming using the field symbols is quiet easy. Once the field symbol is assigned correctly, it can be used just like any other variable in ABAP program. Below are shown some simple field symbol usages in different scenarios. Loop on internal tables using field symbols: DATA : <fs_wa> TYPE ANY. LOOP AT itab ASSIGNING <fs_wa>. ** Do Processing **
ENDLOOP. Read on internal tables using field symbols: READ TABLE itab ASSIGNING <fs_wa> INDEX i. Important Note: Remember - that field symbols point to the memory area. So this could be used to modify contents of internal tables while looping on them without actually writing a modify statement. Isn't that cool.. So how does it work ? When we loop or read a internal table assigning the field symbol, the field symbol points to the memory area that contains the data in work area. So once you modify any field using field symbol like this : <fs_wa>-field_1 = value_1 the contents of the internal tables are modified instantaneously. This is because we have updated the memory directly. So in this case we need not write the explicit MODIFY statement. Thus it is fast (in terms of performance) and the code also looks quiet elegant.
|