Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using Field symbols

Former Member
0 Likes
741

Hi guys,

I have a query.I have wriiten a ABAP program to transfer a csv file to a database table without using field symbols.Now I have another program which uses field symbols.Performance of both the programs are equal.

Which code would you suggest I should go for.i.e which is the best practice.

Regards

Ankit

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
719

Field symbols are generally used for two main purposes.

The first is to handle a dynamic naming and creation when you don't know what is coming.

The second is to reduce code on common named fields.. IE RB10001 RB10002. In this option you can drastically reduce the code to be written by building the names.

Field Symbols WILL take longer for large processing because it has to resolve addressing to the dynamic field.

4 REPLIES 4
Read only

Former Member
0 Likes
719

I would choose for field symbols. it is more flexible to use when you have other tables or import files to handle.

Read only

Former Member
0 Likes
720

Field symbols are generally used for two main purposes.

The first is to handle a dynamic naming and creation when you don't know what is coming.

The second is to reduce code on common named fields.. IE RB10001 RB10002. In this option you can drastically reduce the code to be written by building the names.

Field Symbols WILL take longer for large processing because it has to resolve addressing to the dynamic field.

Read only

0 Likes
719

Field Symbols WILL take longer for large processing because it has to resolve addressing to the dynamic field.

This statement is a little misleading. It depends on the situation. For example, if you where looping at an internal table with a huge amount of records, you would want to use field-symbols because you WILL get better performance.

Loop at itab assiging <wa>.

endloop.

In the above example, we are reading the body of the internal table directly by assign a field symbol to it. Which is faster than doing this.

Loop at itab into wa.

endloop.

In the above example, the system has to copy the contents of the row to the work area, which takes more time then using a field symbol.

Regards,

Rich Heilman

Read only

0 Likes
719

Hi,

this is what I also think. Another advantage of field symbols is, when you want to change data within internal tables in LOOP you don't have to use the MODIFY statement ([Changing Lines|http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb35eb358411d1829f0000e829fbfe/frameset.htm]) cause the field-symbol provides direct access to the field it points to.

If you want to LOOP over a table with a small amount of entries then it could be faster to user workareas instead of field-symbols. Some say for internal tables with up to 100 lines it could be better to use workareas. But I think it depends on severeal things and has to be tested in every case.

Regards Rudi