Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Field Symbols..

Hi team,

              I  am totally confused with the concept of field symbols. Some one said it is a pointer and some one says it is a place holder and so on...

I am not able to get the actual picture behind this concept. Could any one please explain with small examples and then i'll go for huge things. Thanks allot in advance.



Former Member
Former Member replied

Hi Sudheer,

The concept is not straightfoward.

But, here are some basic facts.

A field symbol is Not a pointer. It is a value at address variable or in other words derefrenced variables.

Field Symbols are just like variables , with the exception that they do not have a memory address assgined to them when the program is loaded in memory and are  free to latch on to any memory address- typically those of variables declared statically in the code ( or in advanced cases, dynamically allocated memory). If they are not generically typed then the type of the variable should match with the field symbol type.

Put simply. field symbols are used to modify the contents of a memory address ( variable ).

Ex : Data : l_int type i,

                  l_int1 type i.

field-symbols :<fs_int> type i.

l_int = 4. Statement does not throw an error , as the memory is allocated .

<fs_int> = 4. ->Statement throws a run time error, because the field symbol has not latched on to any memory.

assign ls_int to <fs_int>.

<fs_int> = 5. - No issues  as the field symbol and the variable l_int are the same, the field symbol acts just like an alias.

Now, the value of l_int is also 5 as <fs_int> also modifies the same memory.

assign ls_int1 to <fs_int> -> now it acts as an alias for l_int1.

A pointer is a variable capable of handling memory addresses only.

Pointers are declared with the 'TYPE REF TO ' addition.

example :data:  l_int_ref type ref to i. ->integer poiner,

                 l_int type i ->integer variable.

field-symbols : <fs_int> type i.

get reference of l_int into l_int_ref. ->now l_int_ref points to the memory address of the variable l_int..

You would typically use the field symbol to access the value at the address pointed to by l_int_ref.

You would do so by using the ->* operator- the de referencing operator.


Example : assign l_int_ref->* to <fs_int>.

Well , this is the best I could do, but the whole concept of memory allocations, variable and pointers are much more and cannot be covered in this post.

Try to see the contents of these different variables in the debugger and you would get a clearer picture.

I hope this helps.



1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question