<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The difference between FIELD-SYMBOL and normal DATA TYPE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847359#M924970</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;fieldsymbol has the same concept as pointer in c,&lt;/P&gt;&lt;P&gt;fieldsymbol don't point to a data type like char, num instead of that it points to the memory block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;form insert_row&lt;/P&gt;&lt;P&gt;using p_tc_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols &amp;lt;tc&amp;gt; type cxtab_control. "Table control&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign (p_tc_name) to &amp;lt;tc&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;insert 100 lines in table control&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;lt;tc&amp;gt;-lines = 100.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 May 2008 03:56:25 GMT</pubDate>
    <dc:creator>JoffyJohn</dc:creator>
    <dc:date>2008-05-23T03:56:25Z</dc:date>
    <item>
      <title>The difference between FIELD-SYMBOL and normal DATA TYPE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847357#M924968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the example below, both are output the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
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 &amp;gt;= 4000.
    EXIT.
  ENDIF.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;--&lt;/STRONG&gt;&lt;DEL&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/DEL&gt;&lt;/P&gt;&lt;HR originaltext="-----------------" /&gt;OR It can be written as--&lt;HR originaltext="-----------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: EXTERNAL_RECORD(4000),
      POSITION TYPE I,
      LENGTH TYPE N.
FIELD-SYMBOLS &amp;lt;ENTRY&amp;gt;.
EXTERNAL_RECORD = '0005Smith0007Edwards0005Young'.
DO.
  LENGTH = EXTERNAL_RECORD+POSITION(4).
  IF LENGTH = 0.
    EXIT.
  ENDIF.
  ADD 4 TO POSITION.
  ASSIGN EXTERNAL_RECORD+POSITION(LENGTH) TO &amp;lt;ENTRY&amp;gt;.
  WRITE &amp;lt;ENTRY&amp;gt;.
  ADD LENGTH TO POSITION.
  IF POSITION &amp;gt;= 4000.
    EXIT.
  ENDIF.
ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there any special circumstances we need to use FIELD-SYMBOL?&lt;/P&gt;&lt;P&gt;Why is FIELD-SYMBOL is introduce in the first place?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly advice with example.&lt;/P&gt;&lt;P&gt;Thanks in advance for those who can help me on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 01:56:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847357#M924968</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T01:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: The difference between FIELD-SYMBOL and normal DATA TYPE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847358#M924969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you read table entries using READ or in a LOOP, you can assign them to a field symbol using the addition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... ASSIGNING &amp;lt;fs&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field symbol &amp;lt;fs&amp;gt; points directly to the assigned line in memory. Unlike work areas, in which the contents of the line are only available indirectly using the INTOaddition, field symbols allow you to read and change table entries directly.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Advantages of Field Symbols&lt;/P&gt;&lt;P&gt;When you read from an internal table, there are no overheads for copying the table line to the work area. When you change an internal table with the MODIFY statement, you must first fill a work area with values, and then assign them to the internal table. If you work with field symbols instead, you do not have this overhead. This can improve performance if you have large or complex internal tables. It also makes it easier to process nested internal tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 03:52:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847358#M924969</guid>
      <dc:creator>JoffyJohn</dc:creator>
      <dc:date>2008-05-23T03:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: The difference between FIELD-SYMBOL and normal DATA TYPE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847359#M924970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;fieldsymbol has the same concept as pointer in c,&lt;/P&gt;&lt;P&gt;fieldsymbol don't point to a data type like char, num instead of that it points to the memory block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;form insert_row&lt;/P&gt;&lt;P&gt;using p_tc_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols &amp;lt;tc&amp;gt; type cxtab_control. "Table control&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign (p_tc_name) to &amp;lt;tc&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;insert 100 lines in table control&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;lt;tc&amp;gt;-lines = 100.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 03:56:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847359#M924970</guid>
      <dc:creator>JoffyJohn</dc:creator>
      <dc:date>2008-05-23T03:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: The difference between FIELD-SYMBOL and normal DATA TYPE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847360#M924971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;HI&lt;/STRONG&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;form insert_row&lt;/P&gt;&lt;P&gt;using p_tc_name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols &amp;lt;tc&amp;gt; type cxtab_control. "Table control&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assign (p_tc_name) to &amp;lt;tc&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;insert 100 lines in table control&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;lt;tc&amp;gt;-lines = 100.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------------------------------------" /&gt;&lt;P&gt;Field symbols allow you to:&lt;/P&gt;&lt;P&gt;**	Assign an alias to a data object(for example, a shortened &lt;/P&gt;&lt;P&gt;        name for data objects structured through several hierarchies&lt;/P&gt;&lt;P&gt;        - &amp;lt;fs&amp;gt;-f instead of rec1-rec2-rec3-f)&lt;/P&gt;&lt;P&gt;**	Set the offset and length for a string variably at runtime&lt;/P&gt;&lt;P&gt;**	Set a pointer to a data object that you determine at runtime (dynamic ASSIGN)&lt;/P&gt;&lt;P&gt;**	Adopt or change the type of a field dynamically at runtime &lt;/P&gt;&lt;P&gt;**	Access components of a structure&lt;/P&gt;&lt;P&gt;**	(from Release 4.5A) Point to lines of an internal table &lt;/P&gt;&lt;P&gt;        (process internal tables without a separate work area)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field symbols in ABAP are similar to pointers in other programming &lt;/P&gt;&lt;P&gt;languages. However, pointers (as used in PASCAL or C) differ from ABAP&lt;/P&gt;&lt;P&gt;field symbols in their reference syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement ASSIGN f to &amp;lt;fs&amp;gt; assigns the field f to field&lt;/P&gt;&lt;P&gt;symbol &amp;lt;fs&amp;gt;. The field symbol &amp;lt;fs&amp;gt; then "points" to the&lt;/P&gt;&lt;P&gt;contents of field f at runtime. This means that all changes to the &lt;/P&gt;&lt;P&gt;contents of f are visible in &amp;lt;fs&amp;gt; and vice versa. You declare&lt;/P&gt;&lt;P&gt;the field symbol &amp;lt;fs&amp;gt; using the statement FIELD-SYMBOLS: &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reference syntax&lt;/P&gt;&lt;P&gt;Programming languages such as PASCAL and C use a dereferencing symbol&lt;/P&gt;&lt;P&gt;to indicate the difference between a reference and the object to which&lt;/P&gt;&lt;P&gt;it refers; so PASCAL would use p^ for a pointer instead of p, C would &lt;/P&gt;&lt;P&gt;use *p instead of p. ABAP does not have any such dereferencing symbol.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**	In PASCAL or C, if you assign a pointer p1 to a pointer p2, &lt;/P&gt;&lt;P&gt;you force p1 to point to the object to which p2 refers (reference semantics).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**	In ABAP, if you assign a field symbol &amp;lt;fs1&amp;gt; to a field &lt;/P&gt;&lt;P&gt;symbol &amp;lt;fs2&amp;gt;, &amp;lt;fs1&amp;gt; takes the value of the data object to&lt;/P&gt;&lt;P&gt;which &amp;lt;fs2&amp;gt; refers (value semantics).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**	Field symbols in ABAP are always dereferenced, that is, &lt;/P&gt;&lt;P&gt;they always access the referenced data object. If you want to &lt;/P&gt;&lt;P&gt;change the reference yourself in ABAP, you can use the ASSIGN statement&lt;/P&gt;&lt;P&gt;to assign field symbol &amp;lt;fs1&amp;gt; to field symbol &amp;lt;fs2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using field symbols&lt;/P&gt;&lt;P&gt;You declare field symbols using the FIELD-SYMBOLS statement. &lt;/P&gt;&lt;P&gt;They may be declared either with or without a specific type.&lt;/P&gt;&lt;P&gt;At runtime you assign a field to the field symbol using the ASSIGN &lt;/P&gt;&lt;P&gt;statement. All of the operations on the field symbol act on the field&lt;/P&gt;&lt;P&gt;assigned to it.&lt;/P&gt;&lt;P&gt;When you assign a field to an untyped field symbol, the field symbol &lt;/P&gt;&lt;P&gt;adopts the type of the field. If, on the other hand, you want to assign &lt;/P&gt;&lt;P&gt;a field to a typed field symbol, the type of the field and that of the &lt;/P&gt;&lt;P&gt;field symbol must be compatible.&lt;/P&gt;&lt;P&gt;A field symbol can point to any data object and from Release 4.5A, &lt;/P&gt;&lt;P&gt;they can also point to lines of internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The brackets (&amp;lt;&amp;gt;) are part of the syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the expression &amp;lt;fs&amp;gt; IS ASSIGNED to find out whether the field&lt;/P&gt;&lt;P&gt;symbol &amp;lt;fs&amp;gt; is assigned to a field.&lt;/P&gt;&lt;P&gt;The statement UNASSIGN &amp;lt;fs&amp;gt; sets the field symbol &amp;lt;fs&amp;gt; so&lt;/P&gt;&lt;P&gt;that it points to nothing. The logical expression &amp;lt;fs&amp;gt; &lt;/P&gt;&lt;P&gt;IS ASSIGNED is then false. The corresponding negative expression &lt;/P&gt;&lt;P&gt;is IF NOT &amp;lt;fs&amp;gt; IS ASSIGNED.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An unassigned field symbol &amp;lt;fs&amp;gt; behaves as a constant with &lt;/P&gt;&lt;P&gt;type C(1) and initial value SPACE.&lt;/P&gt;&lt;P&gt;MOVE &amp;lt;fs&amp;gt; &lt;/P&gt;&lt;P&gt;TO dest	Transfers the initial value SPACE to the variable dest&lt;/P&gt;&lt;P&gt;MOVE 'A' to &amp;lt;fs&amp;gt;	&lt;/P&gt;&lt;P&gt;Not possible, since &amp;lt;fs&amp;gt; is a constant &lt;/P&gt;&lt;P&gt;(runtime error).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To lift a type restriction, use the CASTING addition in the&lt;/P&gt;&lt;P&gt;ASSIGN statement. The data object is then interpreted as though&lt;/P&gt;&lt;P&gt;it had the data type of the field symbol. You can also do this&lt;/P&gt;&lt;P&gt;with untyped field symbols using the CASTING TYPE &amp;lt;type&amp;gt; addition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The danger with pointers is that they may point to invalid areas. &lt;/P&gt;&lt;P&gt;This danger is not so acute in ABAP, because the language does not &lt;/P&gt;&lt;P&gt;use address arithmetic (for example, in other languages, pointer p &lt;/P&gt;&lt;P&gt;might point to address 1024. After the statement p = p + 10, it would&lt;/P&gt;&lt;P&gt;point to the address 1034). However, the danger does still exist, and&lt;/P&gt;&lt;P&gt;memory protection violations lead to runtime errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A pointer in ABAP may not point beyond a segment boundary. ABAP does&lt;/P&gt;&lt;P&gt;not have one large address space, but rather a set of segments. &lt;/P&gt;&lt;P&gt;Each of the following has its own segment:&lt;/P&gt;&lt;P&gt;*	All global data&lt;/P&gt;&lt;P&gt;*	All local data&lt;/P&gt;&lt;P&gt;*	Each table work area (TABLES)&lt;/P&gt;&lt;P&gt;*	Each COMMON PART&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should only let field symbols move within an elementary field or&lt;/P&gt;&lt;P&gt;structure where ABAP allows you to assign both within the global data&lt;/P&gt;&lt;P&gt;and beyond a field boundary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;Umakanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 04:14:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/the-difference-between-field-symbol-and-normal-data-type/m-p/3847360#M924971</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T04:14:40Z</dc:date>
    </item>
  </channel>
</rss>

