Performance Field Symbols Vs Work Area

Hi,
I want to some operations (Validations and Calculations) form each entry of internal table.
Which is better way to access the data in internal table either using field symbol or using work area?
I heard that using filed symbols is performance issue. May I know in which cases we should not use field symbols?
Regards,
Kumar

I do not think, the runtime creates a pointer to each line of the itab.
The developer creates ONE fieldsymbol ( for a loop for example ) --> a pointer, which is iteratively assigned, pointing to only one line at one time.
With the usage itself it  seems to offer a benefit, which isn't really one, If You only read data.
People might say, You can omit a clear, if working with fieldsymbols.
But You have to add a check for sy-subrc, or You will suffer from a dump, which usually never happens, if working with work areas the same way, like fieldsymbols.
The real benefit only comes into play, if You want to modify the data in the internal table, because You are already acting on the line of the table (pointer to record n ), what allows You, to omit any modify to transfer changed values back to the internal table.
In terms of performance I must see it technically and I hope, someone can confirm/reject my statement, so that I (if I was wrong) could keep that in mind.
A fieldsymbol (lets talk about them in technical way, as a pointer) is in fact a variable, which holds an address of another variable( which itself also can hold an address and so on).
Pointers are either 4 byte or 8 byte. So, it does not matter, how much columns Your internal table has, technically the fieldsymbol is either 4 byte big or 8 byte big. And exactly this amount is used in the ram of the application server.
In fact pointers even do not have a type, as usual pointers are always integer.
A workarea is a linear, continous allocation of memory space, exacly matching the data-structure, which is used for declaration. So it is obvious, that this workarea uses much more memory of the ram, as long their elements exceed 4 / 8 bytes.
Still then it is not more performant, because changed data of a workarea has to be transferred to the internal table, (mostly, if one wants to modify), but with field-symbols this step is removed.
So in fact there are two technical reasons for using field-symbols.
One is, You save memory-space and the second is, You save the transferring.
In an even deeper way, one can say, that , by design, a cpu with its address bus is just intended to understand addresses best ( directly after 0 and 1 and hex ).

Similar Messages

  • 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

  • Field symbol to work area

    Hello experts,
                       I am getting a problem while working with field symbols. I have some data field symbol in the form of structure. The field symbols have the type 'TABLE' so the data fills in runtime, so the structure also changes runtime. We need to get some fields out form them in the work area.
        How can I do that? Is there any code you can give me so that I can use that.
    Please help.
    Thanks,
    Ganesh

    Hello,
    Use the Assign statement.
    Try like this.
      LOOP AT <FS_1> ASSIGNING <FS_2>.
        ASSIGN COMPONENT  'POSIDFROM'
        OF STRUCTURE  <FS_2>  TO <FS_5>.
        LV_POSID = <FS_5>.
    endloop.
    Cheers,
    Vasanth

  • Field symbols not working in data transfer VOFM routine

    Hi,
    I have been trying to set a value using field symbols, however for some reasons its not working. I am using a field symbol in a data transfer routine and the value which I am trying to set is a standard field outside the VOFM routine code.
    I am trying to set a  field gla_subrc which is actually a changing parameter.
    The actual paramter is gn_subrc of type sy-subrc and within the form the name is gla_subrc. I need to set this changing parameter gla_subrc using the data transfer routine.
    Is there a specific rule that field symbols dont work for changing paramters within subroutine or is there a specific syntax.
    The syntax I am using is
    ASSIGN ('(SAPLV50S)gla_subrc')  to <fs>. 
    I also used the local program name instead of main program but still that does not work. Tried using the actual parameter as well.
    Can someone please help me in this.
    Thanks & Regards,
    Naresh.

    I need to stop outbound delivery creation against STO using vl10b transaction. The only way to stop creation is using data transfer delivery VOFM routine.
    If i give an error message MESSAGE E001, this will give a hard error which is not acceptable. To avoid this, i use a perform message statment with message id and certain parameters which can displayed in a log.
    However to make sure this message is displayed in log, I am clearing a work area having specific data needed for delivery creation.
    Because of this clear, my error message gets captured in log but along with this another fake message is displayed in log which caused by the clear message.
    The user gets confused as he now sees 2 messages, 1 which is correct and other 1 which is fake and that confuses him.
    Data transfer routine is not the best place to give messages in log but we have very few options. The only way the system can give 1 message is if i set gla_subrc to 1. This is a variable which will help the system understand that the delivery should not be created as there is something wrong because the value is 1. Hence it will stop the creation and instead display whatever message i had passed to the log.
    I need to somehow set this variable to 1 based on lot of analysis that has been done in the past.
    Please let me know if there is any way by which we can fix this.
    Thanks & Regards,
    Naresh.

  • Dynamic field modification in Work Area.

    Hi,
    I want to insert 1 record in a transparent table. (But for time being, let us assume the table is MARA)
    The columns and table name to which data is to be inserted are stored in another transparent table say (z1354_inv_rec_dt).
    The data to be inserted is specified in a text file.
    The value for MATNR, let us assume is hard coded as 1252.
    The value for fields ERSDA, ERNAM, LAEDA and AENAM will be specified in input text file.
    Also the table z1354_inv_rec_dt, will have rows with values ERSDA, ERNAM, LAEDA and AENAM.
    How do I do this, the code specified in form comparedata is not correct one, but just a starting point for code.
    <b>So how do I specify the column of work area at run time and assign value to it.</b>
    Then I have to append value from work area to internal table.
    And from internal table, I will insert to database.
    REPORT ZDYN_INS_MARA.
    TYPE-POOLS : abap.
    DATA:
      lit_z1354_inv_rec_dt  TYPE TABLE OF z1354_inv_rec_dt,
    * table z1354_inv_rec_dt contains 2 columns column_name and table_name
    * values for column_name are ERSDA, ERNAM, LAEDA and AENAM
    * value for table_name is MARA.
      lwa_invoice LIKE  z1354_inv_rec_dt,
      lit_mara TYPE TABLE OF mara,
      lwa_mara LIKE mara.
    * To get column names
    DATA :
      it_details TYPE abap_compdescr_tab,
      wa_details TYPE abap_compdescr,
      ref_descr TYPE REF TO cl_abap_structdescr.
    FIELD-SYMBOLS : <fs_mara> TYPE mara.
    FIELD-SYMBOLS : <fs_wa_mara> LIKE LINE OF lit_mara.
    FIELD-SYMBOLS : <dyn_field>.
    DATA: int_tabname(30).
    int_tabname = 'MARA'.
    *Populate internal table with columns to be added to Database
    PERFORM populaterecdt.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( int_tabname ).
    *Get the column names from the Database tables
    it_details[] = ref_descr->components[].
    PERFORM comparedata.
    *&      Form  PopulateRecDt
    FORM populaterecdt .
      SELECT column_name table_name FROM z1354_inv_rec_dt
      INTO CORRESPONDING FIELDS OF TABLE lit_z1354_inv_rec_dt
      WHERE table_name = 'MARA' .
    ENDFORM.                    " PopulateRecDt
    *&      Form  CompareData
    FORM comparedata .
    *loop through the DB table which holds the column names to be added
    LOOP AT lit_z1354_inv_rec_dt INTO lwa_invoice.
    *Loop throught table which holds the column names
      ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_wa_mara> TO <dyn_field>.
      <dyn_field> = '1252'   .
      LOOP AT it_details INTO wa_details.
        IF wa_details-name = lwa_invoice-column_name.
    * Assign value to column of work area from text file.
          ASSIGN component lwa_invoice-column_name of structure                   <fs_wa_mara> to <dyn_field>.
    *Get value for <dyn_field> from text file
            <dyn_field> = 'XYZ212'.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
    *append work area t to lit_mara.
    *Append work area to internal table.
    *insert the internal table to DB
    ENDFORM.                    " CompareData
    Here in this loop, I want to assign to the work area for Mara based on the column values, How do I do it.
    Regards,
    Vikas

    Hi,
    This problem has been resolved.
    DATA:
        lit_MARA TYPE TABLE OF MARA,
        lit2_MARA TYPE TABLE OF MARA,
        lwa_MARA LIKE MARA,
        lit_inv TYPE TABLE OF z1354_inv_rec_dt,
        wa_inv  LIKE z1354_inv_rec_dt,
        sctemp(100) TYPE c,
        ifs type i,
         p_gs_s_rec_line TYPE string.
      FIELD-SYMBOLS:
        <fs_MARA> TYPE table,
        <ld_column>   TYPE ANY,
        <fs_wa_MARA> LIKE LINE OF lit_MARA.
    *Populate Invoice table
      SELECT * FROM  z1354_inv_rec_dt INTO CORRESPONDING FIELDS OF TABLE
      lit_inv WHERE recordtype = 'S' AND table_name = 'MARA' AND
      column_seq > 0.
      p_gs_rec_line = '1234567890000001'.
      lwa_MARA-laufi = '123e'.
      FREE lit_MARA.
      APPEND  lwa_MARA TO lit_MARA.
      ASSIGN lit_MARA[] TO <fs_MARA>.
      UNASSIGN: <fs_wa_MARA>.
    * free lit_MARA[] .
    * LOOP AT <fs> ASSIGNING <fs1>.
    LOOP AT lit_MARA ASSIGNING <fs_wa_MARA>.
      ifs = sy-tabix.
      write: / ifs.
        LOOP AT lit_inv INTO wa_inv.
          WRITE
          p_gs_s_rec_line+wa_inv-start_pos_extrac(wa_inv-chars_to_extract)
          TO sctemp.
          UNASSIGN: <ld_column>.
          ASSIGN COMPONENT wa_inv-column_name OF STRUCTURE <fs_wa_MARA>
          TO <ld_column>.
          <ld_column> =  sctemp.
          IF ( <ld_column> IS ASSIGNED ).
            WRITE: / '.' .
          ENDIF.
          CLEAR wa_inv.
        ENDLOOP.
        MOVE  <fs_wa_MARA> TO lwa_MARA.
        APPEND lwa_MARA TO lit2_MARA.
       CLEAR <fs_wa_MARA>.
      ENDLOOP.
    loop at lit2_MARA into lwa_MARA.
      write: / lwa_MARA-filename.
      clear lwa_MARA.
    endloop.
    insert MARA from table lit2_MARA.
    if sy-subrc <> 0.
      write: / ' Insert  :-( '.
    endif.

  • To find the field in the work area and pass to some field

    Hi all,
    My Requirement is something like this .
    i have 2 records in my internal table and i the value which i require may be anywhere in that internal table .
    Eg.
                     NODE     NODEDESC    PSPHI        PARENT      CHILD     ZLEFT       ZRIGHT
                      ASD         XCCC           ASD                            R.00002
                      CDD         CCCCC         CDD             GHJ
                       FGB         FFFF            R.000005     RFG
                       GHJ        CCCC            CDD             CDD         RFG
    Records look like the above pattern so i want to capture the values like R.00002 or any value which resembles R.------
    as i need to pass these things to my another function module my question is R.---- can be in any field so how can i get that values.
    please help me
    Hope i am clear with my question.
    Regards,
    Sana.

    Hi,
    Try this way..
    Suppose my internal table has 3 fields(A1,A2,A3) and i have two records.
    A1 A2 A3
    g1   t 2   R1
    t1   R1   t2
    Loop at itab.
    var1 = itab-A1.
    var2 = itab-a2
    var3 = itab-a3.
    if var1 CA 'R'.
    move var1 to some variable.
    elseif var2 CA '2'.
    move var2 to some variable.
    elseif var3 CA 'R'.
    Move var3 to some variable.
    endif.
    clear : itab,
               var1,
               var2,
              var3.
    endloop.
    Regards,
    Nagaraj

  • Read dynamic field symbol Work Area before append to dynamic table

    Hi experts:
    I have a dynamic work area but before doing an append to the dynamic table, I need to do some validation on some fields of the work area in order to decide to append it or not, but I don't know how...
    More or less this is the example
    loop at so_kschl.
        field = so_kschl-low.
        if <t_dyntable>-field = 0. "if the value of this field in dinamic table is 0.
    don't append
        else.
           APPEND <fs_dyntable> TO <t_dyntable>.  
        endif.
    endloop.
    Thank you very much for your help.
    Miriam

    Check this example, you read the component of the dynamic work area and assign it to a field-symbols. In this case, I validate that the entry is always 'a'.
    DATA: i_lvc TYPE lvc_t_fcat WITH HEADER LINE,
          i_table TYPE REF TO data,
          l_style TYPE lvc_fname,
          l_warea TYPE REF TO data,
          l_name(7) VALUE 'VARCHAR'..
    FIELD-SYMBOLS: <fs> TYPE table,
                  <fs2> TYPE ANY,
                  <fs3> TYPE ANY.
    PARAMETERS p_char TYPE c LOWER CASE.
    START-OF-SELECTION.
      i_lvc-fieldname = 'Varchar'.
      i_lvc-inttype = 'C'.
      i_lvc-intlen = 1.
      APPEND i_lvc.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
      it_fieldcatalog = i_lvc[]
      IMPORTING
      ep_table = i_table
      e_style_fname = l_style.
      ASSIGN i_table->* TO <fs>.
      CREATE DATA l_warea LIKE LINE OF <fs>.
      ASSIGN l_warea->* TO <fs2>.
      <fs2> = p_char.
      ASSIGN COMPONENT l_name OF STRUCTURE <fs2> TO <fs3>.
      IF <fs3> = 'a'.
        WRITE: 'Component VARCHAR is a'.
    *  APPEND <fs2> TO <fs>.
      ELSE.
        WRITE: 'Component VARCHAR is not a'.
      ENDIF.

  • How to assign values to a work area which is a Field Symbol?

    Hello Experts!
    I really need your help! this is the problem:
    I need to assign values to fields into a work area which is a field symbol. The values come from a flat file I uploaded and as I can't know the length I had to build the structure dynamically ( That's why I'm using FS). Each field comes from the file separated by ';', I tried using the SPLIT sentence:
    "SPLIT text AT ';' INTO TABLE <dyn_table>." but the values are assigned vertically into the same field instead of horizontally into each field of the table(field-symbol table).
    I know the name of the field dynamically
    (a TEXT + number) and I know I can't do this
    <dyn_wa>-TEXT1 or field_name = 'TEXT1' <dyn_wa>-(field_name).... ohhh I'm blocked, I don't seem to find the answer, please help!
    Thanks in advance!!
    Frinee

    Now that you have a table with the values, you can move them to the work area.
    data: begin of wa,
          fld1(20) type c,
          fld2(20) type c,
          fld3(20) type c,
    *     and so on
          end of wa.
    data: istr type table of string with header line.
    field-symbols: <fs>.
    split text at ';' into table istr.
    loop at istr.
    assign component sy-tabix of structure wa to <fs>.
    if sy-subrc <> 0.
    exit.
    endif.
    <fs> = istr.
    endloop.
    write:/ wa-fld1, wa-fld2, wa-fld3.
    Now, WA has the values in a horizontal fashion.
    Regards,
    Rich Heilman

  • Field-symbols working

    Hi Friends,
    I am facing some problems with regards to handling of Field-symbols.
    1.  How can we do a move-corresponding like thing with a FIELD_SYMBOL. We have two Field-symbols and both are referring to lines in Internal tables. But there are some less fields in the Second Field-symbol(Work Area i.e. TYPE TABLE) than the First FIELD-SYMBOL(Work Area i.e. TYPE TABLE). I need to move the values in the Second using the First Field-symbol. How can we do this.
    I cannot do an Assign component as I cannot provide the Fieldname in the Second Field-symbol(Work Area).
    2. the Second problem is how can we clear any particular Field in the field-symbol(TYPE TABLE).
    Thanks and Regards,
    Arunava

    Hello Arunava,
    When you declare your field symbols, declare it like this:
    FIELD-SYMBOLS: <fs1> like line of ITAB1,
                   <fs2> like line of ITAB2.
    Then for
    1. After you have assigned the record to corresponding field symbols, you can do this statement
        MOVE-CORRESPONDING <fs1> to <fs2>
    2. You can do like this to clear individual fields
       LOOP AT ITAB1 assigning <fs1>.
          CLEAR <fs1>-field1.
          MODIFY ITAB1.
       ENDLOOP.

  • Dynamic access to work area fields

    Hi
    I've got a DataBase table with 20 fields with different names.
    field1
    field2
    field3.
    field20
    I'm using a work area to read values and i wanna read an specific field of this work area.
    The problem is the following:
    I don't know the name of the field i need to access, instead, i have it in a field symbol.
    Is there any way i can get the value of this field???

    Hi,
    Try the following example
      DATA: i_TAB           LIKE PA0001 OCCURS 0 WITH HEADER LINE,
            l_field(50)     TYPE C,
            l_fieldname(50) TYPE C VALUE 'UNAME'.
      FIELD-SYMBOLS: <fieldxx> TYPE ANY,
                     <valxx>   TYPE ANY.
      ASSIGN l_fieldname TO <fieldxx>.
      SELECT * FROM PA0001 INTO TABLE I_TAB.
      LOOP AT I_TAB.
        CONCATENATE 'I_TAB-' <fieldxx> INTO l_field.
        ASSIGN (l_field) TO <valxx>.
        WRITE <valxx>.
      ENDLOOP.

  • How to merge work areas of same internal table

    Hi Experts,
    I have a requirement to merge two work areas into 3rd work area where all 3 belonging to same internal table like example below.
            person | activity | location |
    wa1: 001     |    A       |              |
            person | activity | location |
    wa2: 001     |              | xyz       |
    after merging the value in wa3 should be as follows:
             person | activity | location |
    wa3: 001      |    A       |  xyz       |
    I am looking for a ABAP command or FM to perform this task.  Please help me on the same.
    Many Thanks,
    Vijay

    Hello,
    Try this:
    Field-symbols: <lfs_wa1> type line of lit1,
                     <lfs_wa2> type line of lit2.
      sort lit2 by field1 ascending.
      loop at lit1 assigning <lfs_wa1>.
        read table lit2 with key field1 = <lfs_wa1>-field1 assigning <lfs_wa2> binary search.
        clear wa3.
        wa3-field1 = <lfs_wa2>-field1.
        wa3-field2 = <lfs_wa2>-field2.
        wa3-field3 = <lfs_wa2>-field3.
        append wa3 to lit3.
      endloop.
    Use sorted internal tables, field symbols and binary search for better performance. In case when different fields in both work areas may be populated for each row, you need to implement some check and move logic inside loop instead of simple value assignment. I assume that the key value is always there for both tables you want to merge.
    best regards,
    Marcin
    Edited by: Marcin Makowski on Oct 20, 2010 7:16 PM
    Edited by: Marcin Makowski on Oct 20, 2010 7:17 PM

  • Field-symbols v/s Object references in OO-ABAP

    Hi,
    can anyone please tell me what is the difference between using field-symbols and object references in OO ABAP? Is there a specific need for field-symbols now that we have references?
    Thanks.
    Shakul.

    Hi ,
    Please note that both Field symbols & Object References are different .
    You can use Field symbols during the following situations
    1) When you want to modify the value of internal table, the field symbol would be useful since you do not have to use any Modify statement as in case of work area. The Field symbol works as a pointer and any changes to the field symbol will directly affect the value of the internal table
    2) Make sure that you do not reassign the field symbol within a Loop iteration
    3) Field symbols are useful when you work with dynamic internal tables ( tables whose structure is determined during run time)
    4) After Read an internal table ( Read itab...) into a Field symbol, make sure you do a Sy-subrc check or check if the field symbol is assigned.IF not this will give you a run time error
    You can use Object References while creating an object to a class. They are instances of a class.
    Thanks,
    Chakram Govindarajan

  • 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

  • Wat is the use of casting in field symbols

    wat is the use of casting in field symbols?

    When you assign a data object to a field symbol, you can cast to any data type. This means that any area of memory can be viewed as having assumed a given type. You can then address parts of fields symbolically without having to use offset/length addressing.
    A cast is performed using the CASTINGaddition of the ASSIGN statement. The CASTINGaddition allows you to assign a data object to a field symbol where the type of the data object is incompatible with that of the field symbol. There are two types of casting: casting with an implicit type declaration and casting with an explicit type declaration.
    For details please have a look at below link:
    [Casting|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3930358411d1829f0000e829fbfe/frameset.htm]
    I hope it helps.
    Thanks,
    Vibha
    Please mark all the useful answers

  • Sort  itab by using field symbol

    All,
    I have a field symbol  that pointing to a field value in work area of an internal table i_sort ( For example work area that contains the field name having a value MATNR' ( this decides only at runtime) )
    My requirement is i need to sort another table for example i_tab (structure same as records in i_sort) using this field symbol.
    Any Info?

    Hi,
    Check the below report sorting table VBAP based on field VBELN dynamically.
    Let me know if u need any clarification.
    REPORT  ZTEST1.
    tables: dd03l.
    field-symbols: <fs1> type any,
                   <fs2> type any.
    data:
       wa_1 type vbak,
       w_index type sy-index.
    data:
      itab like standard table of vbap,
      ftab like standard table of dd03l.
      select * from vbap into table itab
               up to 10 rows.
    select single * from vbak into wa_1 where vbeln ne space.
    assign wa_1-vbeln to : <fs1>,
                           <fs2>.
    do.
      assign component sy-index of structure wa_1 to <fs1>.
      if <fs1> = <fs2>.
        w_index = sy-index.
        exit.
      endif.
    enddo.
    select *
      from DD03L
      into table ftab
    where TABNAME eq 'VBAK'.
    sort ftab by position.
    read table ftab with key position = w_index into dd03l.
    sort itab by (dd03l-FIELDNAME).
    Thanks,
    - Ram

Maybe you are looking for