on 04-18-2006 12:19 AM
Hello Gurus,
Could you explain a little what is the comparison?
Which is more advisable to use?
Thanks,
Alfonso
hi alfonso,
Field Symbol are like pointer to memory in ABAP.Field symbols points to the assigned data object in memory and doesn't take separate memory. If you change the contents of field symbol, it will actually change the content of memory location, it is pointing to. So you are changing the assigned object.
here are some more links to field symbols
http://www.sapgenie.com/abap/code/chap2401.txt
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb38c8358411d1829f0000e829fbfe/frameset.htm
hope it is useful..
regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In addition to above:
Field symbols help to access data objects dynamically.It allows to access and pass data objects whose name and attributes we do not know until runtime.
Its not necessary to specify the type of the field that will be assigned to it.It will inherit the properties of whatever type that is assigned to it at run-time.
Field symbols are very much useful for dynamic programming.Field symbols also improve Performance.
But field symbol has limited security checks since fields are assigned till runtime. Hence there is more chance for error.
Incorrect data assignments may create problem since detecting the problem is very difficult.
so you should be more clear about field symbols. But it will help you lot once you master it...
Regards,
Prema
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Experts,
Reference to links given above, with the syntax : "FIELD-SYMBOLS <FS>." does it mean that I can simply change the field assigned to FS by replacing the field name? Reason for asking is that when I did that, I got the dump message 'GETWA_NOT_ASSIGNED' when loading data package.
Am i right to say that once assigned, if there is change in field assignment to FS, the <FS> must be changed to eg. <FS1>?
Thanks,
Alfonso
Hi A.H.P,
Its similar to your sample.
I see from your links that <fs> need not be <fs>, can be any word eg. <PT>.
I have asked my colleague, who wrote it originally, but he does not want to tell me straight answer. He said its advanced level stuff. He said he is a consultant, not supposed to teach. He charge for advice. So I am seeking help here.
I tried replacing the zfield with zfield1 for all such occurrences in the short code. That is when I got the abend. My hunch is that somehow the <fs> becomes reserved? Once assigned to zfield, it cannot be used by another field? I should use <fs1>?
Hope someone could give me the hint.
Many thanks,
Alfonso
Hi Alfonso,
If you want to reuse the same field-symbol then you should first unassign it using command UNASSIGN <fs>.
It means the code may look like.
Field-symbols <FS>.
Assign data_package-field1 to <FS>.
*--- Update the <FS>.
Unassign <FS>.
Assign data_package-field2 to <FS>.
*---- Update the <FS>.
But if both of your fields are from the same structure then you can assign that structure to the field symbol. i.e.
Assign data_package to <FS>.
<FS>-field1 = 'ABCD'.
<FS>-field2 = 'EFGH'.
Let me know if you have any doubts.
Regards,
Rohit
Hi,
Internal tables are some sort of static memory occupiers and field symbols are dynamic memory occupiers.
Help says:
About Internal Table:
<i>Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.</i>
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/frameset.htm
Field symbol:
<i>Field symbols are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.</i>
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
With rgds,
Anil Kumar Sharma .P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.