Skip to Content
author's profile photo Former Member
Former Member

Field Symbol

Hi All,

I want to know the use of Field Symbol with simple examples. Can any one help me. thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Jan 11, 2007 at 08:22 AM

    field symbol doen't hold data.it contains of address of that variable.

    field symbol can be declared as, field-symbols<fs1>

    eg:

    data:x type i.

    x = 100.

    field-symbols<fs1>.

    assign x to <fs1>.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:20 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 08:21 AM

    Hai

    Go through the following Document & Example for Field Symbols

    Go through the following Link

    This documentation should answer your question. I use field symbols when using dynamic programming.

    Just go through these links.

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/frameset.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/content.htm

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/content.htm

    Field-Symbols are place holders for existing fields.

    A Field-Symbol does not physically reserve space for a field but points to a field, which is not known until run time of the program.

    Field-Symbols are like Pointers in Programming language ‘ C ‘.

    Syntax check is not effective.

    Syntax :

    Data : v1(4) value ‘abcd’.

    Field-symbols <fs>.

    Assign v1 to <fs>.

    Write:/ <fs>.

    DATA: BEGIN OF LINE,

    COL1 TYPE I,

    COL2 TYPE I,

    END OF LINE.

    DATA ITAB LIKE SORTED TABLE OF LINE WITH UNIQUE KEY COL1.

    FIELD-SYMBOLS <FS> LIKE LINE OF ITAB.

    DO 4 TIMES.

    LINE-COL1 = SY-INDEX.

    LINE-COL2 = SY-INDEX ** 2.

    APPEND LINE TO ITAB.

    ENDDO.

    READ TABLE ITAB WITH TABLE KEY COL1 = 2 ASSIGNING <FS>.

    <FS>-COL2 = 100.

    READ TABLE ITAB WITH TABLE KEY COL1 = 3 ASSIGNING <FS>.

    DELETE ITAB INDEX 3.

    IF <FS> IS ASSIGNED.

    WRITE '<FS> is assigned!'.

    ENDIF.

    LOOP AT ITAB ASSIGNING <FS>.

    WRITE: / <FS>-COL1, <FS>-COL2.

    ENDLOOP.

    The output is:

    1 1

    2 100

    4 16

    Regards

    Sreeni

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2007 at 08:23 AM

    Hi,

    Field sumbols are used generally for dynamic programming. When you use generic type like ANY it is very useful.

    See the code below.

    CLASS demo IMPLEMENTATION.

    METHOD main.

    DATA: wa(10) TYPE c VALUE '0123456789'.

    DATA: BEGIN OF line1,

    col1(3) TYPE c,

    col2(2) TYPE c,

    col3(5) TYPE c,

    END OF line1.

    DATA: BEGIN OF line2,

    col1(2) TYPE c,

    col2 TYPE sy-datum,

    END OF line2.

    • correct --------------------------------------------------------------

    FIELD-SYMBOLS: <f1> LIKE line1,

    <f2> LIKE line2.

    ASSIGN wa TO: <f1> CASTING,

    <f2> CASTING.

    • obsolete, not supported in methods -----------------------------------

    "FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,

    " <f2> STRUCTURE line2 DEFAULT wa.

    • ----------------------------------------------------------------------

    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,

    / <f2>-col1, <f2>-col2.

    ENDMETHOD.

    ENDCLASS.

    START-OF-SELECTION.

    demo=>main( ).

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.