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

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 is the difference between document class and normal class

    Hi,
    Please let me know what is the difference between document class and normal class.
    And I have no idea which class should call as document class or call as an object.
    Thanks
    -Actionscript Developer

    the document class is invoked immediately when your swf opens.  the document class must subclass the sprite or movieclip class.
    all other classes are invoked explicitly with code and need not subclass any other class.

  • What's the difference between segment filtering and reduced message type

    Hi gurus,
    What's the difference between segment filtering and reduced message type? It seems they have the same functionality: Reduce the segment while idoc is generated.
    Thanks in advance.

    Hi,
    BD53 is for IDoc Reduction.
    this allows you to create a reduced message based upon a standard message type.If you want see mandatory fields. go to T-coe BD53 and give one standard messege type name and eg: matmas
    there mandatory fields will be in Green color..
    And BD56- This transaction is used to filter out segments of IDocs for combination of sender and receiver. This is usefull in scenarios where a standard IDoc with many segments is used but the receiving partner is only interested in some of the segments
    the table related to this transation is TBD20
      please go through below blog you have an idea abt that,
    http://wiki.sdn.sap.com/wiki/display/ABAP/ReducedMessageTypes
    http://saptotal.com/IDoc%20Segment%20Filtering.html
    regards,
    ganesh.

  • 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,
    Kathir

    Hi
    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

  • What is the difference between CE Portal and normal Portal

    Can someone tell me the difference between CE Portal & Normal Portal. I mean, I keep hearing that SAP EP 7.2 is CE portal whereas SAP EP 7.3 is not CE portal.
    Can I assume that CE (Composite environment) is a failure model so SAP switched back to Non-CE environment ? Your inputs please.

    Hello,
    SAP NetWeaver Composition Environment 7.1 and 7.2 have been introduced as a lean "side-car" approach to complement the SAP NetWeaver standard release. Main reason was to provide composition tools and services based on a enhanced Java technology stack (back the time).
    The official successor of SAP NetWeaver 7.0 (or any of the enhancements packages) has been SAP NetWeaver 7.3 (where we brougth various tools together back into one SAP NetWeaver codeline.) Nowadays we recommend the latest release: SAP NetWeaver 7.4 including the Enterprise Portal 7.4.
    Customers & Partners who did not want to install the full SAP NetWeaver Java stack had the chance to only go with the Composition Environment - that contained selected portal core services. These are mainly used for application integration / launching scenarios and not supportin full enterprise portal (intranet / extranet) scenarios - that's why there is no KM included.
    Hope this helps to get a better understanding.
    Regards,
    Thomas

  • What is the difference between Bex transportation and Normal Transportation

    Hi experts,
    I have doubt with Transporting queries , in this I've used the normal transport (truck icon) rather than Bex Transport. I would like to know which is the preferable one and what is the main difference between them.
    Suggest me if I can go for normal Transportation rather than Ibex transport, as I've  not tried Bex transportation before.
    Give me some valuable inputs please.......
    Regards
    Kumar

    Hi Kumar,
    We have a Bex transport because we may make changes in the query very often and these changes will be automatically taken care by Bex transports.
    Generally this is how it goes.
    You will capture the queries by creating a transport request and immediately you will create a Bex transport request and  you have to assign the previously created transport request number to this Bex transport request, so that everytime you make changes to the query will be taken care by the Bex transport.
    You can even create a Bex transport request individually.
    Hope this tip may be useful.
    Assign points if you find useful
    Thanks
    Regards
    Sam Mathew

  • What is the difference between materialised view and normal view?

    please expalin the difference in detail with an example.
    thanks.

    Hi User,
    Welcome to Forum !!!!
    Materialized view is nothing but a database Object similar to Tables,Indexes,Procedures etc.
    It contains the results of a query.
    The materialized view is refreshed when the query is executed. And are refreshed on demand
    Unlike Views, it contain data.
    It does not contain real-time data.
    Materialized view are called Snapshot(In Older Versions of Oracle).
    Thanks,
    Shankar

  • What is the difference between joint stereo and normal stereo?

    When I go to the importing options and click custom, it asks if I want it to import in joint stereo or normal stereo. Can someone tell me what the difference is? I want to do whichever one sounds better.

    Try Google:
    http://www.google.com/search?q=jointstereo+vs.stereo
    Also:
    I want to do whichever one sounds better.
    If you can' tell the difference, go with the default.

  • What's the difference between OpenGL advanced and normal modes?

    I get that Basic mode uses the cpu and Normal uses the gpu, but what exactly does Advanced mode do?
    The description says that it uses as much of the GPU as Normal Mode does, but adds "advanced techniques to improve drawing performance."
    Has anyone seen one of these advanced techniques  in action or know of a list of these mysterious improved capabilities?

    What CC said... Imagine a shader having say a length of 32 discrete instructions/steps vs. one with 16... The 32 one will concatenate specific operations in one step and may thus be more optimized, but will not work on a card that does not provide those 32 shader cores, since it could not be executed in one clock cycle. Then you would use the 16 one with instructions being split across 2 cycles... That's all there is to it and for al lintents and purposes mostly irrelevant and unimportant to the user...
    Mylenium

  • Which is the difference between field mode and frame mode in interlacing?

    Which is the best one for moving objects?

    An interlacing camera actually takes two pictures to create each picture you see. These pictures are taken a fraction of a second apart, which allows the object of interest to move.
    First, the camera takes a picture using the odd lines of the sensor. This is the first field. About 1/60 of a second later, it takes a picture using the even lines of the camera. This is the second field. The two pictures are combined by the frame grabber by interlacing the lines, which creates the frame you normally see as the image.
    In frame mode, the two fields are combined to make a single image. In field mode, you get the odd lines as an image, and the even lines as a separate image.
    When capturing a moving object, it is best to use a progressive scan (non-interla
    ced) camera, which takes a picture using all of the lines simultaneously.
    If you only have an interlaced camera, your best option is probably field mode, because the object doesn't have a chance to move. There are a couple of drawbacks to field mode, though. The height of your image is only half what it should be, which distorts everything and makes it difficult for measurements and the like. Also, the odd and even images are shifted by one line, so the live image appears to vibrate slightly if there is a lot of detail. You can't compare two consective images, because they are odd and even fields.
    I hope this helps.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Need to know the difference between SRM workflow and Normal Ecc 6.0 Worflow

    Hi All,
    I have worked on Ecc 6.0 worflow, just wanted to know how is SRM workflow going to be different than the ECC6.0 worflows.
    Incase if someone can suggest some links for tutorials for SRM workflow basics.
    Thanks to all in advance.
    Anu.

    Hi
    In addition to Masa
    For every business object we do have one or more  work flow templates are available.
    In SRM , you can approve via web browsers . very user friendly screens
    br
    muthu

  • Difference between Preffered Vendor and Normal/Fixed Vendor

    Hi Experts,
    Can any one tell me the difference between Preffered Vendor and Normal/Fixed Vendor . And the concept behind
    those.
    Thanks in Advance.

    what is difference between preferred and ordinary vendor, partial conf&conf

  • Difference between ISU ABAP and normal ABAP

    Hi ,
    Can anyone tell me what is the difference between ISU ABAP and normal ABAP..Is there any difference..if So..what is the difference...also it will be veryuseful if any one has document regarding ISU ABAP..
    Thanks & Regards.
    Srini.

    Hi,
    From technical point of view, there is no difference, Instead of using R/3 tables you will be using IS-U tables in you select queries etc...
    Functionally there are differnce in ISU and R/3 (SD/MM/PM/FI etc..)
    Regards
    Shiva

Maybe you are looking for

  • How to hide subfolders in Outlook view in iPhone

    Need to hide all subfolders tht comes over from Outlook into my iPhone, takes forever to scroll down when all is showing. Is there a way?

  • There are some strange problems when i used swc files in my as3 project

    Hello everyone,         My development environment:  fdk4.0,  flash cs5.5,  I publish fla file by using flash cs5.5,   publish setting is  fp version :10.0&10.1 ->swc. I imported swc files to my as3 project and  complied them by using flex sdk4.0. Wh

  • Process code error

    I am getting error in IDOC. Its giving a error in Status Records i.e 51 error no. Its giving a error message that Function MOdule APPL_IDOC_INPUTI is not found. Can you please let me know what should be the problem. Thanks, vinay.

  • BACKGROUND JOB WAS NOT SCHEDULED/LOG FILE NOT YET GENERATED

    Hello, To generate the log report, /VIRSA/ZVFATBAK program is scheduled on hourly basis but some time report doesn't get generated and if we see the background job then it shows sucessfully finished. If we see the maually the log report for FFID then

  • App Store updates won't download after selecting the 'Update" button.

    I received a notification that I had a couple of updates on the App Store. I'm running 10.6.8 on an Early 2009 iMac 9,1. After entering my account information I selected the "update" button for both apps. The button fades to indicate it has been sele