Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

If we compare field symbol and data refernece with that of the pointer in C i concluded that :-

In C language, Say we declare a variable "var" type "Integer" with default value "5".

The variable "var" will be stored some where in the memory and say the memory address which holds this variable is "1000".

Now we define a pointer "ptr" and this pointer is assigned to our variable.

So, "&ptr" will be "1000" and " *ptr " will be 5.

Lets comapre the above situation in SAP ABAP.

Here we declare a Field symbol "FS" and assign that to the variable "var".

Now my question is what "FS" holds ? I have searched this rigorously in the internet but found out many ABAP consultants have the opinion that FS holds the address of the variable i.e. 1000. But that is wrong. While debugging i found out that fs holds only 5. So fs (in ABAP) is equivalent to *ptr (in C). Please correct me if my understanding is wrong.

Now lets declare a data reference "dref" and another filed symbol "fsym" and after creating the data reference we assign the same to field symbol . Now we can do operations on this field symbol. So the difference between data refernec and field symbol is :-

in case of field symbol first we will declare a variable and assign it to a field symbol.

in case of data reference first we craete a data reference and then assign that to field symbol.

Then what is the use of data reference? The same functionality we can achive through field symbol also.

share|improve this question

closed as not constructive by Jalayn, Walter, Yusubov, Mark Trapp, ChrisF Oct 11 '12 at 21:38

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

1 Answer

The field-symbol is much like a pointer, but one that you can only access in a dereferenced form. In other words, it will hold, internally, the memory address of the variable that was assigned to it, but it will not allow you to see the memory address, only the data that is stored in the variable that it points to. This can be proved, because if you change the contents of a field-symbol that points to an internal table line, you'll see that the changes will be made directly in the line.

A data reference acts like a simple pointer, except that you can't increment or decrement the memory address like in C (ptr++, ptr-- and such). It differs from a field-symbol because you can compare two data references to check if they point to the exact same spot in the memory. Comparing two field-symbols will be a simple value comparison. Another difference is that you can allocate memory dynamically by creating data references, with the CREATE DATA command. A field-symbol can only be assigned to an already allocated variable.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.