Field symbols and field groups
Hi friends plz send me the answer for this query:
What are field symbols and field groups.? what is the"component idx of structure" clause with field groups?
Hi,
A field group combines several existing fields together under one name
like
FIELD-GROUPS: fg.
then you can use one insert statement to insert values in fields of field-group.
INSERT f1 f2 ... INTO fg.
Field symbols
If u have experience with 'C', then understand this to be similar to a pointer.
It is used to reference another variable dynamically. So this field symbol will simply point to some other variable. and this pointer can be changed at runtime.
FIELD-SYMBOLS <FS>.
DATA FIELD VALUE 'X'.
ASSIGN FIELD TO <FS>.
WRITE <FS>.
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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
Field Groups / Extracts
http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
Field Symbols
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
Regards,
Priyanka.
Similar Messages
-
Difference between Field symbols and field group
Hi experts,
Can you please advice me what is the difference between field symbols and field groups.
Thanks in advance,
Logu.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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
A field group combines several existing fields together under one name
like
FIELD-GROUPS: fg.
then you can use one insert statement to insert values in fields of field-group.
INSERT f1 f2 ... INTO fg.
Field symbols
If u have experience with 'C', then understand this to be similar to a pointer.
It is used to reference another variable dynamically. So this field symbol will simply point to some other variable. and this pointer can be changed at runtime.
FIELD-SYMBOLS <FS>.
DATA FIELD VALUE 'X'.
ASSIGN FIELD TO <FS>.
WRITE <FS>.
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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
example :
DATA: BEGIN OF SPTAB OCCURS 0,
line(1000), " or type string
END OF SPTAB.
DATA: IDX LIKE SY-INDEX.
field-symbols <FS1>.
split tb_sip AT ';' INTO table sptab.
LOOP AT SPTAB.
IDX = IDX + 1.
ASSIGN COMPONENT IDX OF STRUCTURE tb_detsip TO <FS1>.
If sy-subrc = 0.
<FS1> = SPTAB-line.
Endif.
Endloop.
append tb_detsip.
clear idx.
Field Groups / Extracts
http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
Field Symbols
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
Reward points if useful. -
Difference between Field symbols and Field groups
<b>Hi Friends,
can you tell me the differences between Field symbols and Field groups? with any examples preferably?
Regards
Dinesh</b>Hi Dinesh,
A field group combines several existing fields together under one name
like
FIELD-GROUPS: fg.
then you can use one insert statement to insert values in fields of field-group.
INSERT f1 f2 ... INTO fg.
<b>Field symbols</b>
If u have experience with 'C', then understand this to be similar to a pointer.
It is used to reference another variable dynamically. So this field symbol will simply point to some other variable. and this pointer can be changed at runtime.
FIELD-SYMBOLS <FS>.
DATA FIELD VALUE 'X'.
ASSIGN FIELD TO <FS>.
WRITE <FS>.
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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
Field Groups / Extracts
http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
Field Symbols
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
Reward points if helpful.
Regards,
Hemant -
What are field symbols and field groups.?
hi,
What are field symbols and field groups.? what is the usage of "component idx of structure" clause with field groups?
regardssorry, question resolved.
-
What are field symbols and field groups.? Have you used "component idx of s
What are field symbols and field groups.? Have you used "component idx of structure"
Field Symbols and field groups
Field Groups / Extracts
http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
Field Symbols
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm
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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
A field group combines several existing fields together under one name
like
FIELD-GROUPS: fg.
then you can use one insert statement to insert values in fields of field-group.
INSERT f1 f2 ... INTO fg.
Field symbols
If u have experience with 'C', then understand this to be similar to a pointer.
It is used to reference another variable dynamically. So this field symbol will simply point to some other variable. and this pointer can be changed at runtime.
FIELD-SYMBOLS <FS>.
DATA FIELD VALUE 'X'.
ASSIGN FIELD TO <FS>.
WRITE <FS>.
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 each field symbol before you can address the latter in programs.
Field Groups:
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
Field Groups / Extracts
http://help.sap.com/saphelp_46c/helpdata/EN/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
Field Symbols
http://help.sap.com/saphelp_46c/helpdata/EN/fc/eb387a358411d1829f0000e829fbfe/frameset.htm -
Fields symbols and field groups
what are field symbols and field groups?
Regards,
sravanthiDifference between Field symbols and Field groups
what are field groups and field symbols ... -
What are field symbols and field groups.? Have you used "component idx of structure" clause with field groups?
Hi
this will help you
reward if usefull
<b><u>FIELD-SYMBOLS</u></b>
<u>Syntax</u>
FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
Extras:
1. ... typing
2. ... STRUCTURE struc DEFAULT dobj
The FIELD-SYMBOLS statement declares a field symbol <fs>. The name conventions apply to the name fs. The angle brackets of the field symbols indicate the difference to data objects and are obligatory. You can declare field symbols in any procedure and in the global declaration section of an ABAP program, but not in the declaration section of a class or an interface. You can use a field symbol in any operand position in which it is visible and which match the typing defined using typing.
After its declaration, a field symbol is initial - that is, it does not reference a memory area. You have to assign a memory area to it (normally using the ASSIGN statement) before you can use it as an operand. Otherwise an exception will be triggered.
<b><u>FIELD-GROUPS</u></b>
<u>Syntax</u>
FIELD-GROUPS { header | field_group }.
Declaration of a field group for the extract dataset of the program. Each field group represents the name of a line structure of the extract dataset. You can create as many field groups as you wish in a program. You define the actual components of a field group with the statement INSERT.
The denominator of a field group is either the predefined name header or any name field_group. If you declare a field group header, it automatically becomes the beginning part of all remaining field groups of the program and its components constitute the standard sort key of the extract dataset for the statement SORT.
The statement FIELD-GROUPS is possible in the global declaration-part of an ABAP program, as well as in the subprograms and function modules. Field groups that are declared in procedures are visible only there.
As you can only define global data objects as components of field groups with the statement INSERT, we recommend to declare field groups only in the global declaration part as well. -
Field Symbols, Field String, and Field Group.
Hi,
Can you differentiate between filed symbols, field strings and field groups,
With regards,
Bharath Mohan BHi,
Field Symbols
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 each field symbol before you can address the latter in programs.
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.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Related
ASSIGN, DATA
Additional help
Declaring Field Symbols
FIELD GROUPS
are used to hold/handle large amount of data when the internal table are not useful
we use EXTRACT statement, HEADER structure in them
see the example
REPORT demo_extract.
NODES: spfli, sflight.
FIELD-GROUPS: header, flight_info, flight_date.
START-OF-SELECTION.
INSERT: spfli-carrid spfli-connid sflight-fldate
INTO header,
spfli-cityfrom spfli-cityto
INTO flight_info.
GET spfli.
EXTRACT flight_info.
GET sflight.
EXTRACT flight_date.
END-OF-SELECTION.
SORT STABLE.
LOOP.
AT FIRST.
WRITE / 'Flight list'.
ULINE.
ENDAT.
AT flight_info WITH flight_date.
WRITE: / spfli-carrid , spfli-connid, sflight-fldate,
spfli-cityfrom, spfli-cityto.
ENDAT.
AT flight_date.
WRITE: / spfli-carrid , spfli-connid, sflight-fldate.
ENDAT.
AT LAST.
ULINE.
WRITE: cnt(spfli-carrid), 'Airlines'.
ULINE.
ENDAT.
ENDLOOP.
FIELD STRING is nothing but a string with one row of records.
Reward points if useful
regards
Anji -
The difference between FIELD-SYMBOL and normal DATA TYPE
Dear experts,
Please see the example below, both are output the same result.
DATA: EXTERNAL_RECORD(4000),
POSITION TYPE I,
LENGTH TYPE N,
ENTRY TYPE STRING.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
LENGTH = EXTERNAL_RECORD+POSITION(4).
IF LENGTH = 0.
EXIT.
ENDIF.
ADD 4 TO POSITION.
MOVE EXTERNAL_RECORD+POSITION(LENGTH) TO ENTRY.
WRITE ENTRY.
ADD LENGTH TO POSITION.
IF POSITION >= 4000.
EXIT.
ENDIF.
ENDDO.
--OR It can be written as--
DATA: EXTERNAL_RECORD(4000),
POSITION TYPE I,
LENGTH TYPE N.
FIELD-SYMBOLS <ENTRY>.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
LENGTH = EXTERNAL_RECORD+POSITION(4).
IF LENGTH = 0.
EXIT.
ENDIF.
ADD 4 TO POSITION.
ASSIGN EXTERNAL_RECORD+POSITION(LENGTH) TO <ENTRY>.
WRITE <ENTRY>.
ADD LENGTH TO POSITION.
IF POSITION >= 4000.
EXIT.
ENDIF.
ENDDO.
Is there any special circumstances we need to use FIELD-SYMBOL?
Why is FIELD-SYMBOL is introduce in the first place?
Kindly advice with example.
Thanks in advance for those who can help me on this.HI,
You can use field symbols to make the program more dynamic. In this example the name of a table control is substituted by a field symbol. Thus you cal call the form with any internal table, using the name of the table control as a parameter.
Example
form insert_row
using p_tc_name.
field-symbols <tc> type cxtab_control. "Table control
assign (p_tc_name) to <tc>.
insert 100 lines in table control
<tc>-lines = 100.
Field symbols allow you to:
** Assign an alias to a data object(for example, a shortened
name for data objects structured through several hierarchies
- <fs>-f instead of rec1-rec2-rec3-f)
** Set the offset and length for a string variably at runtime
** Set a pointer to a data object that you determine at runtime (dynamic ASSIGN)
** Adopt or change the type of a field dynamically at runtime
** Access components of a structure
** (from Release 4.5A) Point to lines of an internal table
(process internal tables without a separate work area)
Field symbols in ABAP are similar to pointers in other programming
languages. However, pointers (as used in PASCAL or C) differ from ABAP
field symbols in their reference syntax.
The statement ASSIGN f to <fs> assigns the field f to field
symbol <fs>. The field symbol <fs> then "points" to the
contents of field f at runtime. This means that all changes to the
contents of f are visible in <fs> and vice versa. You declare
the field symbol <fs> using the statement FIELD-SYMBOLS: <fs>.
Reference syntax
Programming languages such as PASCAL and C use a dereferencing symbol
to indicate the difference between a reference and the object to which
it refers; so PASCAL would use p^ for a pointer instead of p, C would
use *p instead of p. ABAP does not have any such dereferencing symbol.
** In PASCAL or C, if you assign a pointer p1 to a pointer p2,
you force p1 to point to the object to which p2 refers (reference semantics).
** In ABAP, if you assign a field symbol <fs1> to a field
symbol <fs2>, <fs1> takes the value of the data object to
which <fs2> refers (value semantics).
** Field symbols in ABAP are always dereferenced, that is,
they always access the referenced data object. If you want to
change the reference yourself in ABAP, you can use the ASSIGN statement
to assign field symbol <fs1> to field symbol <fs2>.
Using field symbols
You declare field symbols using the FIELD-SYMBOLS statement.
They may be declared either with or without a specific type.
At runtime you assign a field to the field symbol using the ASSIGN
statement. All of the operations on the field symbol act on the field
assigned to it.
When you assign a field to an untyped field symbol, the field symbol
adopts the type of the field. If, on the other hand, you want to assign
a field to a typed field symbol, the type of the field and that of the
field symbol must be compatible.
A field symbol can point to any data object and from Release 4.5A,
they can also point to lines of internal tables.
The brackets (<>) are part of the syntax.
Use the expression <fs> IS ASSIGNED to find out whether the field
symbol <fs> is assigned to a field.
The statement UNASSIGN <fs> sets the field symbol <fs> so
that it points to nothing. The logical expression <fs>
IS ASSIGNED is then false. The corresponding negative expression
is IF NOT <fs> IS ASSIGNED.
An unassigned field symbol <fs> behaves as a constant with
type C(1) and initial value SPACE.
MOVE <fs>
TO dest Transfers the initial value SPACE to the variable dest
MOVE 'A' to <fs>
Not possible, since <fs> is a constant
(runtime error).
To lift a type restriction, use the CASTING addition in the
ASSIGN statement. The data object is then interpreted as though
it had the data type of the field symbol. You can also do this
with untyped field symbols using the CASTING TYPE <type> addition.
The danger with pointers is that they may point to invalid areas.
This danger is not so acute in ABAP, because the language does not
use address arithmetic (for example, in other languages, pointer p
might point to address 1024. After the statement p = p + 10, it would
point to the address 1034). However, the danger does still exist, and
memory protection violations lead to runtime errors.
A pointer in ABAP may not point beyond a segment boundary. ABAP does
not have one large address space, but rather a set of segments.
Each of the following has its own segment:
* All global data
* All local data
* Each table work area (TABLES)
* Each COMMON PART
You should only let field symbols move within an elementary field or
structure where ABAP allows you to assign both within the global data
and beyond a field boundary.
Rgds
Umakanth -
Difference between Field symbols and work area for Internal tables
Hi,
In ECC versions we all know that we need to declare the internal tables without headerline, and for handling the internal tables we need to use exclusive work areas.
Currently i have an issue that we have been asked to use field symbols instead of work areas...can any one help me how to use the field symbols and also let me know how it will improve the performance of the program..
Thanks and Regards,
KathirHi
DATA: WA TYPE ITAB.
LOOP AT ITAB INTO WA.
IF WA-FIELD = .....
ENDIF.
ENDLOOP.[(code]
FIELD-SYMBOLS <WA> TYPE ANY.
LOOP AT ITAB ASSIGNING <WA>.
ENDLOOP.
Now the problem is you can't know the name of the fields of the table at runtime, so you can't write:
IF <WA>-FIELD = .....
ENDIF.
Anyway you can create a field-symbols strcturated like the table:
[code]FIELD-SYMBOLS <WA> TYPE ITAB.
LOOP AT ITAB ASSIGNING <WA>.
IF <WA>-FIELD = .....
ENDIF.
ENDLOOP.
I don't know which are the differences for the performance between to use a field-symbol and to use a structure as work-area.
The differnce between the field-symbols and work-area is the field-symbol is assigned directly to the record, so u don't need to do a MODIFY statament to change something:
LOOP AT ITAB INTO WA.
WA-FIELD =
MODIFY ITAB FROM WA.
ENDLOOP.
LOOP AT ITAB ASSIGNING <WA>.
<WA>-FIELD =
ENDLOOP.
These two pieces of abap code do the same action, so probably the field-symbol improve the performance because it do an access directly to the record without to use an external structure as workarea.
Max -
Re: field symbols and interna table
hi,
here is field symbol which is table type
FIELD-SYMBOLS: <gt_pos_data> TYPE table.
there is one internal table it_data.
how can move <gt_pos_data> to it_data.
please help me.
rgdsHi
You can assign field wise:
like
<gt_pos_data>- field to to it_data-field.
Field Symbols
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 each field symbol before you can address the latter in programs.
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.
check the below links u will get the answers for your questions
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
Syntax Diagram
FIELD-SYMBOLS
Basic form
FIELD-SYMBOLS <fs>.
Extras:
1. ... TYPE type
2. ... TYPE REF TO cif
3. ... TYPE REF TO DATA
4. ... TYPE LINE OF type
5. ... LIKE s
6. ... LIKE LINE OF s
7. ... TYPE tabkind
8. ... STRUCTURE s DEFAULT wa
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
Effect
This statement declares a symbolic field called <fs>. At runtime, you can assign a concrete field to the field symbol using ASSIGN. All operations performed with the field symbol then directly affect the field assigned to it.
You can only use one of the additions.
Example
Output aircraft type from the table SFLIGHT using a field symbol:
FIELD-SYMBOLS <PT> TYPE ANY.
DATA SFLIGHT_WA TYPE SFLIGHT.
ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
WRITE <PT>.
Addition 1
... TYPE type
Addition 2
... TYPE REF TO cif
Addition 3
... TYPE REF TO DATA
Addition 4
... TYPE LINE OF type
Addition 5
... LIKE s
Addition 6
... LIKE LINE OF s
Addition 7
... TYPE tabkind
Effect
You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
Effect
Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
Example
Address components of the flight bookings table SBOOK using a field symbol:
DATA SBOOK_WA LIKE SBOOK.
FIELD-SYMBOLS <SB> STRUCTURE SBOOK
DEFAULT SBOOK_WA.
WRITE: <SB>-BOOKID, <SB>-FLDATE.
Related
ASSIGN, DATA
Additional help
Declaring Field Symbols
Reward points if useful
Regards
Anji -
ABAP field symbols and PERL reference variables to unnamed arrays.
Rob -
Please do NOT delete this post even though it contains this link:
ABAP field symbols and PERL reference variables to unnamed arrays.
to a question I posted in the Scripting Languages forum.
It's a question that should be of interest to ABAP programmers, and they may miss if they don't frequent the SL forum ...
Thanks for your forbearance here (in advance, of course) ...
Best
djh
Edited by: Rob Burbank on Jul 11, 2011 1:26 PMIf interested, please reply in the original thread. We don't want multiple conversations at cross purposes do we?
Rob -
Are field symbols and Dynamic internal tables consistant?
Hi,
Are field symbols and Dynamic internal tables
always consistent?
In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
this happens once in 3 to 4 runs
any solution...
I have proper clear and refresh statements in program.
Thanks,
HardikAnurag,
Thanks for a quick reply. Here I am sending a small piece of my code.
MOVE-CORRESPONDING OUTTAB TO DYNTAB.
CLEAR IT_UDATE.
CLEAR : T_KBETR .
READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
ASSIGN (T_KBETR) TO <FS> .
SUBRC5 = SY-SUBRC .
IF SUBRC5 = 0 .
<FS> = OUTTAB-KBETR .
ENDIF .
read statement will always return CO_POS .
while debuging this code a few times
<b>ASSIGN (T_KBETR) TO <FS> .</b>
returns sy-subrc = 4
and that was leading the program to short dump earlier.
now, as I have a check DYNTAB-KBETR holds no value on display.
this happens very few times. (most of the times report is displaying desired output)
Thanks,
Hardik -
Field symbols and data extract
hi frenz,
Can anybody please give me details about <b><i>field symbols</i></b> and <b><i>data extracts</i></b> what is the purpose of using them and regarding the performance issues for the two.....
if some one explains with an example its going to be fine......
Please don tell me to refer the 980 or help document.....
Please help me outField symbols offer functionlity similar to pointers in other programming languages. It does not occupy memory for the data object, it points to the object that has been assigned to the field symbol. You use the assign command to relate to the data object. After the assign operation you can work with field symbol in the same way as with the object itself.
You define the field symbol as: field-symbols <fs>.
field-symbol <fs>.
data field value 'X'.
asssign field to <fs>.
The field symbol <fs> now inherits all the properties from the assigned field, and you can work with the field symbol in the same way as with the field itself. -
Reg: Field Symbol and Data Reference
Hi,
What is the difference Between a FieldSymbol and Data Reference.
could anyone explain with an example the difference.
The Link I am Going Through ---> [SAP HELP|http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm]
I couldnt get a clear idea
regardsHi,
In ABAP/4 programs, field symbols are placeholders for existing fields. A field symbol does not physically reserve space for a field, but points to a field, which is not known until runtime of the program. Field symbols are comparable to the concept of pointers as used in the programming language C. In ABAP/4, however, there is no real equivalent to pointers in the sense of variables, which contain a memory address and can be used without the content operator. You can only work with the data object to which a field symbol points.
uF076 Concept of Field Symbols
Sometimes you only know which field you want to process, and how you want to process it, at runtime.
For this purpose, you can create field symbols in your program. At runtime, you can assign real fields to such field symbols. All operations, which you have programmed with the field symbol, are then carried out with the assigned field. After successful assignment, there is no difference in ABAP/4 whether you reference the field symbol or the field itself.
Field symbols can point to any data object in ABAP/4 and to structures defined in the ABAP/4 Dictionary.
You can create field symbols either without or with type specifications. In the first case, the field symbol adopts all the attributes of the assigned field. In the second case, the system checks during the assignment process whether the assigned field matches the type of the field symbol. Whichever applies, you must first assign a field to your field symbol before you can work with it in your program.
Field symbols provide some features that make them very flexible:
uF071 You can specify the offset and length of the assigned field as variables.
uF071 You can assign field symbols to other field symbols and even specify offset and length there.
uF071 Assignments to field symbols may extend beyond field boundaries. This allows effective access to regularly stored data.
uF071 You can force a field symbol to be of a different type and to have a different number of decimal places than the assigned field.
uF071 Field symbols may have a structure that you can use to point to individual components of structures.
Since you can assign data objects to field symbols which may not be known 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. Therefore, you should use field symbols only in cases where you are absolutely sure of what you are doing, or if there are no other ABAP/4 statements you can use to solve your problem. The advantage of field symbols is that they can improve response times in some cases.
uF076 Defining Field Symbols
uF0D8 Defining Field Symbols for Internal Fields
To define a field symbol for an internal data object, use the FIELD-SYMBOLS statement as follows:
Syntax-
FIELD-SYMBOLS <FS> [<type>].
This statement defines a field symbol <FS>.
for data reference follow this link
http://help.sap.com/saphelp_nw04s/helpdata/en/14/11e70b0c5c11d3b9350000e8353423/frameset.htm
Regards,
Flavya
Maybe you are looking for
-
Single click folder name to expand folder in folder view?
As with prior versions, in [Windows] Explorer's main window, you can enable hovering to select and single clicking to expand the folder (but that is a pain in the rear when working with files). Windows XP folder view nicely allowed single clicking th
-
Did what it said online by many uninstalled reinstalled repaired uninstalled reinstalled updated all my registry files all is current Windows 7 premium 64 bit dell.................... I can access my music nor can I update anything on my ipad ipod te
-
How to get first index in ListItemCollectionPosition
Hi Every One I have one issue in SPList.ListItemCollectionPosition. it is return second page start index( query). I need to get first page index(query). I am using following code. int totalItemCount = SPWeb.Lists.TryGetList("ListName").ItemCount;
-
E4200 USB Mapping network drive
nevermind - found my mistake -.-
-
I recently decided to use an AEX as my router and discovered an issue. My setup before the AEX was as follows: Cable modem -> Router -> 2 ethernet hubs linked together. When I replaced the router with the AEX nothing connected to the hub would connec