2008 Jun 06 3:27 PM
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
2008 Jun 06 3:33 PM
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.
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
2008 Jun 06 3:31 PM
I would choose for field symbols. it is more flexible to use when you have other tables or import files to handle.
2008 Jun 06 3:33 PM
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.
2008 Jun 06 3:41 PM
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
2008 Jun 06 4:00 PM
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