Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

field symbols

Former Member
0 Kudos

Hi,

when is recommended to use field symbols and when not?

Regards

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

A field symbol is a pointer that you can assign dynamically to a field.

Memory is allocated to a field symbol during runtime only.

Assign statement is used to assign a field to it.

For example:


DATA: F1(3) VALUE 'XYZ'.

FIELD-SYMBOLS <f>.
ASSIGN F1 to <f>.

Regards,

Ferry Lianto

6 REPLIES 6

Former Member
0 Kudos
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. 

Here U see <a href="http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm">full information</a>. But FIELD-SYMBOLS is just instrument. You must decide using it or not.

0 Kudos

Hi,

Other very important point is that field symbol is much faster than using workarea, especially with READ and LOOP statement. Simply because the data moved from header line to workaera cost much more than pointing directly to it with field symbol.

Field symbol should also be use in cases where you determined dynamically (not know in advance) the type of your local variable.

Hopping this answer your question.

Sincerely,

Alain Gauthier

Former Member

Former Member
0 Kudos

FIELD-SYMBOLS <fs>.

Declares a symbolic field with the name <fs>. At runtime, you can assign a concrete field to it using the ASSIGN statement. Any operations that you then perform using the field symbol directly affect the field that is assigned to it.

Advantage:

-


The main advantage is while processing the records inan internal table and appending to another internal table.

Just assign the values directly to fieldsymbol and no need to used append.

It increases the performance of the program.

Regards,

Satish

ferry_lianto
Active Contributor
0 Kudos

Hi,

A field symbol is a pointer that you can assign dynamically to a field.

Memory is allocated to a field symbol during runtime only.

Assign statement is used to assign a field to it.

For example:


DATA: F1(3) VALUE 'XYZ'.

FIELD-SYMBOLS <f>.
ASSIGN F1 to <f>.

Regards,

Ferry Lianto

Former Member
0 Kudos

HI

Field Symbols can be used if you want to populate work area having some serial

fields for eg : g_r_week1 to g_r_week10 .

LOOP AT ITAB.

CONCATENATE 'G_R_FILE-BWEEK' sy-tabix INTO l_f_week.

ASSIGN (l_f_week) TO <fsname>.

IF sy-subrc = 0.

CONDENSE:g_r_data_option1-weekno.

<fsname> = g_r_data_option1-weekno+4(2).

ENDIF.

ENDLOOP.

Hope this helps .

Praveen