The only advantage that I see, is when using them to access fields or fields of tables dynamically.
Regards,
Rich Heilman
hi,
it's an example.
I've to initializate all fields of a table. I used it in a batch input standard.
...
perform init_table using 'BLFA1'.
.....
form init_table using name_tb type string.
DATA vn_n TYPE i.
FIELD-SYMBOLS <g> TYPE ANY.
field-symbols <tb> type any.
assign (name_tb) to <tb>.
<tb>-STYPE = '1'. "I know that all tables I'll pass to
"this form have the STYPE component
clear vn_n.
do.
add 1 to vn_n.
assign component vn_n of structure <tb> to <g>.
if sy-subrc ne 0.
exit.
endif.
if <g> is initial.
move bgr00-nodata to <g>.
endif.
enddo.
endform.
For more information you con go to the eLearning zone of sdn https://www.sdn.sap.com/sdn/elearning.sdn?node=linkpnode1
in eLearning Repository there is the ABAP link.
there in the Advanced course
https://www.sdn.sap.com/sdn/elearning.sdn?page=el_abap.htm
there is a class Information
Advanced and Generic Programming in ABAP
it explain you because and how use field symbos .
bye
enzo
FIELD-SYMBOLS <fs>.
Declares a symbolic field with the name <fs>. At runtime, you can assign a concrete field to it using the ASSIGN statement. Any operations that you then perform using the field symbol directly affect the field that is assigned to it.
Advantage:
-
The main advantage is while processing the records inan internal table and appending to another internal table.
Just assign the values directly to fieldsymbol and no need to used append.
It increases the performance of the program.
Regards,
Add comment