Iterating On a Table Using Field Symbols

Say you have a Table called “table_name”, of line type “table_row”, and you wish to iterate on it and perhaps change the rows while you’re iterating. You can do it in ABAP using field symbols.
First, you need to define the field symbol. In our example it’s called “symbol_name”

FIELD-SYMBOLS <symbol_name> TYPE table_row.

Now, you can iterate over the table, assigning each row to the field symbol

LOOP AT table_name ASSIGNING <symbol_name>.

On each iteration, you can manipulate the table using the field symbol. Any change done to the field symbol is also done on the table. It’s like using a pointer in C or a reference variable in C++.

Important note: When using field symbols on sorted or hashed table, then you may not change the key fields of these tables. Doing so results in a runtime error. The logic is simple: changing the key will change the sorting order or hashing order of the table, and since you’re in mid-iteration, it may cause you to re-iterate on these rows. You Java developers out there may be familiar with this concept, as it also exists in Java.

You can read more about field symbols at the following SAP help link.


Cub Training January 26, 2015 at 10:53 AM  

After reading this post I got an idea about on this note.Really something grate in this article ,Thanks for sharing this. We are providing SAP courses training online. After reading this slightly am changed my way of introduction about my training to people. To know more Visit Us SAP PM Online Training Course

Viswa March 23, 2015 at 2:15 AM  

Excellent Article,I like Your Post and very informative,very Inseparable,keep sharing us.

Tekslate Trainings July 13, 2015 at 1:05 AM  

nice tutorials for learners, for more any query and training, free demo and tutorials can visit....

Check this site Tekslate for in sap abap Training
Go here if you’re looking for sap abap Training

peterjohn September 10, 2015 at 7:25 AM  

This is one awesome blog article. Much thanks again.
I really enjoy the blog.Much thanks again. Really Great.

oracle online training
sap fico online training
dotnet online training

peterjohn September 10, 2015 at 7:26 AM  

Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!

sap online training
software online training
sap sd online training
hadoop online training

About This Blog

This blog contains tips, tricks, tutorial, and some of my personal experiences with the SAP ABAP language.

FEEDJIT Live Traffic Feed

  © Blogger templates The Professional Template by 2008

Back to TOP