cancel
Showing results for 
Search instead for 
Did you mean: 

Advantage of using Field Symbols

Former Member
0 Kudos

Hi ,

What is tha advantage of using field symbols.

Regards

Arun

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

The only advantage that I see, is when using them to access fields or fields of tables dynamically.

Regards,

Rich Heilman

Answers (3)

Answers (3)

Former Member
0 Kudos

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,

Former Member
0 Kudos

Hi,

Field symbols are quite good for dymanic assignments and accesses. When you change their value, you actually change the value of the object, that they are assigned to. That's why for int.tables you don't need to use MODIFY stmt.

Svetlin

Former Member
0 Kudos

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