Application Development 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: 

Difference between Fieldsymbols and Structures

0 Kudos

Hello,

As i understand it Fieldsymbols are just pointing on columns or rows from Tables, but dont copy or save them.

Strucutes on the other hand are making copy of the Data and holding them, so they dont change the table directly like a field symbol.

Is this correct ?

1 ACCEPTED SOLUTION

matt
Active Contributor

No, it's not correct.

Fieldsymbols are just pointing on columns or rows from Tables

Wrong: Field symbols are references (like pointers) to any kind of data - the row of a table, an entire table, a structure, a field in a structure, at single field, an RTTS dynamically constructed data type...

but dont copy or save them

Neither wrong nor right. Copy or saving is irrelevant. If you change a field-symbol that's changing the data itrefers to.
Strucutes on the other hand are making copy of the Data and holding them, so they dont change the table directly like a field symbol.

Wrong. Structures are just structured data types. They contain fields and may be even internal tables.

From context I'm guessing you're talking about the difference between:

LOOP AT itab ASSIGNING FIELD-SYMBOL(<wa>).

and

LOOP AT itab INTO DATA(wa).

The former puts a reference of the current line of the internal table into the field symbol <wa>. Change <wa> and you are changing the record in itab.

The latter copys the data in the current line of the internal table into the structure (or possibly just a field) wa. If you change wa nothing happens to itab.

4 REPLIES 4

Abhishek_10
Participant

yes you are right.

In a nutshell field symbols are like a reference, so when you make a change there it directly changes the data in table. And structure is like a copy, so if you change there, if just changes data locally in that structure not in the table.

TarunTakshak
Participant

Hi michel1209,

Yes field-symbols points the data at run-time only and work area holds the data

Check

https://answers.sap.com/questions/4444137/use-of-field-symbols--work-area.html

Thanks

Tarun

matt
Active Contributor

No, it's not correct.

Fieldsymbols are just pointing on columns or rows from Tables

Wrong: Field symbols are references (like pointers) to any kind of data - the row of a table, an entire table, a structure, a field in a structure, at single field, an RTTS dynamically constructed data type...

but dont copy or save them

Neither wrong nor right. Copy or saving is irrelevant. If you change a field-symbol that's changing the data itrefers to.
Strucutes on the other hand are making copy of the Data and holding them, so they dont change the table directly like a field symbol.

Wrong. Structures are just structured data types. They contain fields and may be even internal tables.

From context I'm guessing you're talking about the difference between:

LOOP AT itab ASSIGNING FIELD-SYMBOL(<wa>).

and

LOOP AT itab INTO DATA(wa).

The former puts a reference of the current line of the internal table into the field symbol <wa>. Change <wa> and you are changing the record in itab.

The latter copys the data in the current line of the internal table into the structure (or possibly just a field) wa. If you change wa nothing happens to itab.

Yes exactly, i was talking about the lower example, thanks for your answer!