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

Difference between Fieldsymbols and Structures

0 Likes
2,075

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
Read only

matt
Active Contributor
2,007

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
Read only

Abhishek_10
Participant
2,007

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.

Read only

TarunTakshak6
Participant
2,007

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

Read only

matt
Active Contributor
2,008

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.

Read only

2,007

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