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

please give me the explanation of this program

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 09:05 AM

    Form the SAP help:

    <i>"FIELD-SYMBOLS

    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. "</i>

    This program gives you a brief explanation on the use of field symbols which are a dynamic way to refer to "objects" in programs, very useful when you have to manage dynamic situations.

    The command ASSIGN f TO <fs> "<i>assigns the field f to the field symbol <fs>. The field symbol <fs> then "points" to the contents of field f at runtime, that is, any change to f is visible in <fs>, and any change to <fs> is visible in f.If you do not specify a type for the field symbol <fs> ( FIELD-SYMBOLS), it inherits the type and attributes of field f at runtime, especially the conversion exit. Otherwise, the system checks whether f and <fs> are compatible when you make the assignment.</i>"

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      In this case, the content of the table ITAB is assigned to an header line...

      And on that "header line" you perform some operations, like assigning 100 to the second row and deletiong the third.

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 09:18 AM

    Hi,

    Field Symbols are used to assign data types dynamically. The table ITAB contains the data like this with two columns Col1 and Col2.

    1 1

    2 4

    3 9

    4 16

    After populating the ITAB. Reading the ITAB and changing the data.

    Reading the ITAB with col2 value '2' and assigning the value to field symbol <FS> by chaging the value from 2 to 100.

    Reading the ITAB with col2 value '3' and assigning the value to field symbol <FS> amd deleting the row with Index 3.

    The given program displays the output like this.

    1 1

    2 100

    4 16

    Regards,

    Jayaram..

    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.