2007 Jan 31 5:54 AM
Hi,
I am fresher & i want to know about field symbol.
2007 Jan 31 5:59 AM
HI,
Field symbol is nothing but a concept similar to the pointers in C/C++.
Its just a place holder and holds a value whatever you pass. It does not have any specific data type and it acquires the type of the data that you store in that variable.
It is defined as : FIELD-SYMBOLS: <a> and value is assigned as:
ASSIGN itab-bukrs to <a>. (Pls chk the syntax).
Regards
Subramanian
2007 Jan 31 5:59 AM
Hi,
<b>Field Symbols</b>
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.
Whenever you address a field symbol in a program, you are addressing the field that is assigned to the field symbol. After successful assignment, there is no difference in ABAP whether you reference the field symbol or the field itself. You must assign a field to a field symbol before you can address it in a program.
Field symbols are similar to dereferenced pointers in C (that is, pointers to which the content
operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables
that contain a memory address (reference) and that can be used without the contents operator,
are reference variables in ABAP Objects.
All operations programmed with field symbols are applied to the field assigned to it. For example,
a MOVE statement between two field symbols moves the contents of the field assigned to the
first field symbol to the field assigned to the second field symbol. The field symbols themselves
point to the same fields after the MOVE statement as they did before.
You can create field symbols either without or with type specifications. If you do not specify a
type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do
specify a type, the system checks the compatibility of the field symbol and the field you are
assigning to it during the ASSIGN statement.
Field symbols provide greater flexibility when you address data objects:
If you want to process sections of fields, you can specify the offset and length of the field
dynamically.
You can assign one field symbol to another, which allows you to address parts of fields.
Assignments to field symbols may extend beyond field boundaries. This allows you to
address regular sequences of fields in memory efficiently.
You can also force a field symbol to take different technical attributes from those of the
field assigned to it.
The flexibility of field symbols provides elegant solutions to certain problems. On the other hand,
it does mean that errors can easily occur. Since fields are not assigned to field symbols until
runtime, the effectiveness of syntax and security checks is very limited for operations involving
field symbols. This can lead to runtime errors or incorrect data assignments.
While runtime errors indicate an obvious problem, incorrect data assignments are dangerous
because they can be very difficult to detect. For this reason, you should only use field symbols if
you cannot achieve the same result using other ABAP statements.
For example, you may want to process part of a string where the offset and length depend on the
contents of the field. You could use field symbols in this case. However, since the MOVE
statement also supports variable offset and length specifications, you should use it instead. The
MOVE statement (with your own auxiliary variables if required) is much safer than using field
symbols, since it cannot address memory beyond the boundary of a field. However, field
symbols may improve performance in some cases.
Rgds,
Prakash
2007 Jan 31 6:03 AM
2007 Jan 31 6:14 AM
Hi,
Symbolic name for a data object to which specific memory areas can be assigned at program runtime. A field sysmbol can be used instead of data objects at operand positions. A field symbol is either generic or fully typed. Field symbols are declared using the FIELD-SYMBOLS statement and are assigned memory areas using ASSIGN.
Also see this link
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/frameset.htm
If you want more examples on field symbols then go to transaction ABAPDOCU. There u will find enough examples.
Regards,
U. Uma
2007 Jan 31 6:25 AM
Hello Poonam,
Hi,
A field symbol is a place holder for a field.A simple program to show the usage of field symbols.You can avoid using work areas:
Report Sample.
FIELD-SYMBOLS: <FS> TYPE SPFLI.
DATA: I_SPFLI TYPE TABLE OF SPFLI .
SELECT * FROM SPFLI INTO TABLE I_SPFLI.
LOOP AT I_SPFLI ASSIGNING <FS>.
WRITE: / <FS>-CARRID, <FS>-CONNID, <FS>-CITYFROM, <FS>-CITYTO.
ENDLOOP.
We have declared a field symbol of type SPFLI and thus we need not use a work area while looping through the internal table.
Refer:
http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_erp2005vp/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
Regards,
Beejal
**Reward if answer is helpful
2007 Jan 31 6:30 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |