Use of FIELD-SYMBOLS

let me know how to use and why to use FIELD-SYMBOLS in the program

Hi,
A field symbol can 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.
Example
DATA: v_char(10).
FIELD-SYMBOLS: <fs>.
ASSIGN v_char to <fs>.
v_char = 10.  " The value for v_char is changed.
write: / <fs>.
Thanks,
Naren

Similar Messages

  • Proper use of Field symbol .. please help

    what is the proper use of field symbol in sap abap ?
    Moderator Message: Please do a proper search for such basic questions.
    Edited by: kishan P on Sep 13, 2010 4:01 PM

    hi Gopal,
    The parameter is used to color a cell in ALV grid.
    See this example how it is used
    http://www.sap-img.com/abap/line-color-in-alv-example.htm
    take a closer look at the code where the info is passed
    MOVE 'MATNR' TO wa_color-fname.
            MOVE '6'         TO wa_color-color-col.
            MOVE '1'         TO wa_color-color-int.
            MOVE '1'         TO wa_color-color-inv.
            APPEND wa_color TO it_color.
    Cheers
    VJ
    If it helps dont forget to mark points

  • How to use different field symbols to append data in a loop

    Hi experts!
    I have to loop over a itab and I want to save different  into one table.
    See my code below:
    DATA: l_hours        TYPE i,
          grfk_ok_code    TYPE sy-ucomm,
          grfk_values     TYPE TABLE OF GPRVAL WITH HEADER LINE,
          grfk_coltxt     TYPE TABLE OF GPRTXT WITH HEADER LINE,
          wa_ztab         TYPE zqm_chq_prueflos,
          l_index      TYPE n,
          l_field      TYPE string,
          l_line_check TYPE string
    FIELD-SYMBOLS:
          <fs_0102>   TYPE ANY,
          <fs_0304>   TYPE ANY,
          <fs_0506>   TYPE ANY,
          <fs_grenze> TYPE ANY
    REFRESH: grfk_values.
    CLEAR:   l_hours.
      LOOP AT ztab INTO wa_ztab.
      AT NEW qase_serialnr.
        CLEAR: l_line_check.
        IF wa_ztab-qase_serialnr CS '-01'
        OR wa_ztab-qase_serialnr CS '-02'.
            grfk_values-rowtxt = 'gelötet'.
            l_line_check = '0102'.
        ELSEIF wa_ztab-qase_serialnr CS '-03'
        OR     wa_ztab-qase_serialnr CS '-04'.
            grfk_values-rowtxt = 'geglüht'.
            l_line_check = '0304'.
        ELSEIF wa_ztab-qase_serialnr CS '-05'
        OR     wa_ztab-qase_serialnr CS '-06'.
            grfk_values-rowtxt = 'unbehandelt'.
            l_line_check = '0506'.
        ELSE.
          grfk_values-rowtxt = 'serialnr_wrong'.
        ENDIF.
      ENDAT.
    ***---------------------------------------------------->
      AT NEW qapp_usern1.
    *   X-axis: values are:0,50,100,...,400
        grfk_coltxt-coltxt = wa_ztab-qapp_usern1.
        SHIFT grfk_coltxt-coltxt LEFT DELETING LEADING '0'.
        APPEND grfk_coltxt.
        UNASSIGN <fs_grenze>.
        CLEAR: l_index, l_field.
        l_index = sy-tabix.
        CONCATENATE 'grfk_values-val' l_index INTO l_field.
        ASSIGN (l_field) TO <fs_grenze>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        <fs_grenze> = 10.
        APPEND grfk_values.
      ENDAT.
      IF l_line_check = '0102'.
          UNASSIGN <fs_0102>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0102>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0102> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0304'.
          UNASSIGN <fs_0304>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0304>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0304> = wa_ztab-cf_dgp.
      ELSEIF l_line_check = '0506'.
          UNASSIGN <fs_0506>.
          CLEAR: l_index, l_field.
          l_index = sy-tabix.
          CONCATENATE 'grfk_values-val' l_index INTO l_field.
          ASSIGN (l_field) TO <fs_0506>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          <fs_0506> = wa_ztab-cf_dgp.
      ENDIF.
    ENDLOOP.
    My goal should be to fill the graphic with 4 Lines:
    1 is boarderline.
    2-3 are the lines with the looped values in "ztab"
    Do I have to use references to write the values in  into different rows of internal table "grfk_values"????
    With this code I want to fill the itab which I need for the GFW_PRES_SHOW function.
    The table I have to commit has the following structure:
    -rowtxt
    -val1
    -val2
    -val31
    EDIT:
    My current output are 2 lines the first has value 0 for each point and the second shows the correct values... The boarder which always should have value 10 is completly not shown.

    hopen this will help
    report zrich_0001 .
    data: begin of itab1 occurs 0,
          fld1(10) type c,
          fld2(10) type c,
          fld3(10) type c,
          end of itab1.
    data: begin of itab2 occurs 0,
        flda(10) type c,
        fldb(10) type c,
        fldc(10) type c,
        end of itab2.
    field-symbols: <fs_table> type table,
                   <fs_wa>,
                   <fs>.
    data: mod_field(10) type c.
    itab1-fld1 = '1'. itab1-fld2 = '2'. itab1-fld3 = '3'. append itab1.
    itab1-fld1 = '4'. itab1-fld2 = '5'. itab1-fld3 = '6'. append itab1.
    itab2-flda = 'A'. itab2-fldb = 'B'. itab2-fldc = 'C'. append itab2.
    itab2-flda = 'D'. itab2-fldb = 'E'. itab2-fldc = 'F'. append itab2.
    assign itab1[] to <fs_table>.
    assign itab1 to <fs_wa>.
    mod_field = 'FLD2'.
    perform modify_table.
    perform write_table.
    assign itab2[] to <fs_table>.
    assign itab2 to <fs_wa>.
    mod_field = 'FLDC'.
    perform modify_table.
    perform write_table.
          FORM modify_table                                             *
    form modify_table.
      loop at <fs_table> into <fs_wa>.
        assign component mod_field of structure <fs_wa> to <fs>.
        <fs> = 'Modified'.
        modify <fs_table> from <fs_wa>.
      endloop.
    endform.
          FORM write_table                                             *
    form write_table.
      loop at <fs_table> into <fs_wa>.
        do.
          assign component sy-index of structure <fs_wa> to <fs>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <fs>.
          else.
            write: <fs>.
          endif.
        enddo.
      endloop.
    endform.
    regards
    navjot
    reward points if helpfull

  • Using ASSIGN - Field Symbol

    I have used
      import <GT_POS_DATA> from memory id 'lines'.
    and have the same{<GT_POS_DATA>} in my zreport. Now I have to sum
    up one field and move it to a variable to be displayed in my report
    output.
    How shld I proceed.
    Thanks in advance.

    Hi,
    Am facing problem over here :
    ASSIGN COMPONENT wkgbtr OF STRUCTURE <WA> TO <FIELD>.
    This is the part of code I used :
    FIELD-SYMBOLS: <gt_pos_data>  TYPE table,
                     <WA> type any,
                     <field> type any.
    LOOP AT <GT_POS_DATA> ASSIGNING <WA>.
    ASSIGN COMPONENT <wa>-wkgbtr OF STRUCTURE <WA> TO <FIELD>.
    lV_tot = lV_tot + <FIELD>.
    ENDLOOP.

  • I can't use my field-symbols in my select statement...

    Hello experts,
    I am have been having problems with my report for the past days. My problem is,
    I declared a dynamic field symbol so that I can use it in my select statement
    instead of the standard internal table. But it is giving me a dump. Below is my code:
    REPORT zfr_forex_rev_acctg
           NO STANDARD PAGE HEADING
           LINE-COUNT 0
           LINE-SIZE 100.
    Data dictionary tables                       *
    TABLES: bsis,
            bsas,
            tcurr,
            t001.
    FIELD-SYMBOLS: <fs_dyntable> TYPE STANDARD TABLE,
                   <fs_dynline>  TYPE ANY,
                   <fs_fld>      TYPE ANY,
                   <fs_data>     TYPE REF TO data,
                   <fs_1>        TYPE ANY,
                   <fs_2>        TYPE ANY TABLE.
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        METHODS: build_table,
                 get_data,
                 combine_data,
                 display_header,
                 display_results.
      PRIVATE SECTION.
        TYPES: BEGIN OF t_bsis_bsas,
                zuonr  TYPE bsis-zuonr,
                gjahr  TYPE bsis-gjahr,
                belnr  TYPE bsis-belnr,
                bldat  TYPE bsis-bldat,
                waers  TYPE bsis-waers,
                blart  TYPE bsis-blart,
                dmbtr  TYPE bsis-dmbtr,
                wrbtr  TYPE bsis-wrbtr,
                hkont  TYPE bsis-hkont,
                amount TYPE bsis-wrbtr,
               END OF t_bsis_bsas.
        DATA: it_bsis_bsas TYPE STANDARD TABLE OF t_bsis_bsas,
              v_counter TYPE i.
      data declarations for internal table
        DATA: lt TYPE lvc_t_fcat,
              ls TYPE lvc_s_fcat,
              fldname(50) TYPE c,
              it_ddfields TYPE TABLE OF ddfield,
              wa_ddfields LIKE LINE OF it_ddfields.
    ENDCLASS.
    CLASS lcl_main IMPLEMENTATION.
    METHOD build_table
      METHOD build_table.
        DATA: lv_from    TYPE bsis-gjahr,
              lv_asof    TYPE bsis-gjahr,
              lv_check   TYPE i,
              lt_data TYPE REF TO data,
              lt      TYPE lvc_t_fcat.
        FIELD-SYMBOLS: <fs_year> TYPE gjahr.
        ASSIGN lv_asof TO <fs_year>.
        lv_from = p_year.
        lv_asof = p_asof+0(4).
        v_counter = lv_asof - lv_from.
        wa_ddfields-fieldname = 'ZUONR'.
        wa_ddfields-position  = '0001'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000018'.
        wa_ddfields-decimals  = '00000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'GJAHR'.
        wa_ddfields-position  = '0002'.
        wa_ddfields-datatype  = 'NUMC'.
        wa_ddfields-leng      =  '000004'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BELNR'.
        wa_ddfields-position  = '0003'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BLDAT'.
        wa_ddfields-position  = '0004'.
        wa_ddfields-datatype  = 'DATS'.
        wa_ddfields-leng      =  '000008'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'WAERS'.
        wa_ddfields-position  = '0005'.
        wa_ddfields-datatype  = 'CUKY'.
        wa_ddfields-leng      =  '000005'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'BLART'.
        wa_ddfields-position  = '0006'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000002'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'DMBTR'.
        wa_ddfields-position  = '0007'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'WRBTR'.
        wa_ddfields-position  = '0008'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'HKONT'.
        wa_ddfields-position  = '0009'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
        wa_ddfields-fieldname = 'AMOUNT'.
        wa_ddfields-position  = '0010'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        DATA: lv_position TYPE i.
        lv_position = 0011.
        WHILE lv_check < v_counter.
         <fs_year> = lv_asof.
          wa_ddfields-fieldname = <fs_year>.
          wa_ddfields-position  = lv_position.
          wa_ddfields-datatype  = 'NUMC'.
          wa_ddfields-leng      =  '000004'.
          wa_ddfields-decimals  = '000000'.
          APPEND wa_ddfields TO it_ddfields.
          lv_asof = lv_asof - 1.
          ADD 1 TO: lv_check, lv_position.
        ENDWHILE.
        CLEAR lv_position.
        lv_position = 1.
        LOOP AT it_ddfields INTO wa_ddfields.
          ls-col_pos   = lv_position.
          ls-row_pos   = lv_position.
          ls-fieldname = wa_ddfields-fieldname.
          APPEND ls TO lt.
          ADD 1 TO lv_position.
        ENDLOOP.
        CLEAR lv_position.
        ASSIGN lt_data TO <fs_data>.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
          it_fieldcatalog = lt
         IMPORTING
          ep_table = <fs_data>
         EXCEPTIONS
          generate_subpool_dir_full = 1
         OTHERS = 2.
        IF sy-subrc <> 0.
        ENDIF.
        ASSIGN <fs_data>->* TO <fs_1>.
        ASSIGN <fs_1> TO <fs_2>.
        ASSIGN <fs_1> TO <fs_dyntable>.
      ENDMETHOD.
    METHOD get_data
      METHOD get_data.
    *get records from BSIS
        SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
        FROM bsis
        INTO  CORRESPONDING FIELDS OF TABLE <fs_dyntable>
        WHERE bukrs = p_bukrs
          AND hkont IN s_hkont
          AND budat <= p_asof.
    *get records from BSAS
        SELECT zuonr gjahr belnr bldat waers blart dmbtr wrbtr hkont
        FROM bsas
        APPENDING CORRESPONDING FIELDS OF TABLE <fs_dyntable>
        WHERE bukrs = p_bukrs
          AND hkont IN s_hkont
          AND budat <= p_asof
          AND augdt > p_asof.
      ENDMETHOD.
    START-OF-SELECTION.
      DATA: main TYPE REF TO lcl_main.
      CREATE OBJECT main.
      CALL METHOD main->build_table.
      CALL METHOD main->get_data.
    Need help on this problem. Thanks a lot guys and take care!

    Hi guys,
    I found out the problem  and Andreas is right. Now, I am having problems when including DMBTR, WRBTR in my select statement. All the others are ok. Here is my modified code. Please suggest what I need to add/modify. Thanks a lot!
    CLASS lcl_main IMPLEMENTATION.
    METHOD build_table
      METHOD build_table.
        DATA: lv_from    TYPE bsis-gjahr,
              lv_asof    TYPE bsis-gjahr,
              lv_check   TYPE i,
              lt_data TYPE REF TO data,
              lt      TYPE lvc_t_fcat.
        FIELD-SYMBOLS: <fs_year> TYPE gjahr.
        ASSIGN lv_asof TO <fs_year>.
        lv_from = p_year.
        lv_asof = p_asof+0(4).
        v_counter = lv_asof - lv_from.
      ZUONR
        wa_ddfields-fieldname = 'ZUONR'.
        wa_ddfields-position  = '0001'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000018'.
        wa_ddfields-decimals  = '00000'.
        APPEND wa_ddfields TO it_ddfields.
      GJAHR
        wa_ddfields-fieldname = 'GJAHR'.
        wa_ddfields-position  = '0002'.
        wa_ddfields-datatype  = 'NUMC'.
        wa_ddfields-leng      =  '000004'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BELNR
        wa_ddfields-fieldname = 'BELNR'.
        wa_ddfields-position  = '0003'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BLDAT
        wa_ddfields-fieldname = 'BLDAT'.
        wa_ddfields-position  = '0004'.
        wa_ddfields-datatype  = 'DATS'.
        wa_ddfields-leng      =  '00008'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      WAERS
        wa_ddfields-fieldname = 'WAERS'.
        wa_ddfields-position  = '0005'.
        wa_ddfields-datatype  = 'CUKY'.
        wa_ddfields-leng      =  '000005'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      BLART
        wa_ddfields-fieldname = 'BLART'.
        wa_ddfields-position  = '0006'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000002'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      DMBTR
        wa_ddfields-fieldname = 'DMBTR'.
        wa_ddfields-position  = '0007'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
      WRBTR
        wa_ddfields-fieldname = 'WRBTR'.
        wa_ddfields-position  = '0008'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000013'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
      HKONT
        wa_ddfields-fieldname = 'HKONT'.
        wa_ddfields-position  = '0009'.
        wa_ddfields-datatype  = 'CHAR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000000'.
        APPEND wa_ddfields TO it_ddfields.
      AMOUNT
        wa_ddfields-fieldname = 'AMOUNT'.
        wa_ddfields-position  = '0010'.
        wa_ddfields-datatype  = 'CURR'.
        wa_ddfields-leng      =  '000010'.
        wa_ddfields-decimals  = '000002'.
        APPEND wa_ddfields TO it_ddfields.
        DATA: lv_position TYPE i.
        lv_position = 0011.
      Additional fields for the years
        WHILE lv_check < v_counter.
          wa_ddfields-fieldname = <fs_year>.
          wa_ddfields-position  = lv_position.
          wa_ddfields-datatype  = 'NUMC'.
          wa_ddfields-leng      =  '000004'.
          wa_ddfields-decimals  = '000000'.
          APPEND wa_ddfields TO it_ddfields.
          lv_asof = lv_asof - 1.
          ADD 1 TO: lv_check, lv_position.
        ENDWHILE.
        CLEAR lv_position.
        lv_position = 1.
        LOOP AT it_ddfields INTO wa_ddfields.
          CASE wa_ddfields-fieldname.
            WHEN 'BLDAT'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-inttype   = 'D'.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'BLDAT'.
            WHEN 'WAERS'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'WAERS'.
            when 'DMBTR'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'DMBTR'.
            when 'WRBTR'.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
              ls-ref_table = 'BSIS'.
              ls-ref_field = 'WRBTR'.
            WHEN OTHERS.
              ls-col_pos   = lv_position.
              ls-row_pos   = lv_position.
              ls-fieldname = wa_ddfields-fieldname.
          ENDCASE.
          APPEND ls TO lt.
          ADD 1 TO lv_position.
        ENDLOOP.
        CLEAR lv_position.
        ASSIGN lt_data TO <fs_data>.
        CALL METHOD cl_alv_table_create=>create_dynamic_table
         EXPORTING
          it_fieldcatalog = lt
         IMPORTING
          ep_table = <fs_data>
         EXCEPTIONS
          generate_subpool_dir_full = 1
         OTHERS = 2.
        IF sy-subrc <> 0.
        ENDIF.
        ASSIGN <fs_data>->* TO <fs_1>.
        ASSIGN <fs_1> TO <fs_2>.
        ASSIGN <fs_1> TO <fs_dyntable>.
      ENDMETHOD.

  • Doubt in using a Field symbols

    Hi gurus,
    i want to use field symbols for a varying fields in a table.
    like my fields are ZPER01 SHKZG01
                              ZPER02 SHKZG02
                              ZPER03 SHKZG03
                             ......ZPER0N SHKZG0N        
    now i have to populate values in this using field symbols how do i do it.(These fields are in a custom table)
    thanks in advance,
    Vanathi
    Edited by: vanathi sekar on May 2, 2008 2:15 PM

    DATA: BEGIN OF text,
            word1 TYPE c LENGTH 4 VALUE 'AAAA',
            word2 TYPE c LENGTH 4 VALUE 'BBBB',
            word3 TYPE c LENGTH 4 VALUE 'CCCC',
            word4 TYPE c LENGTH 4 VALUE 'DDDD',
          END OF text.
    DATA: word  TYPE c LENGTH 4,
          char1 TYPE c LENGTH 1,
          char2 TYPE c LENGTH 1,
          leng TYPE i.
    FIELD-SYMBOLS <word> LIKE text-word1.
    DATA inc TYPE i.
    DESCRIBE FIELD text LENGTH leng IN CHARACTER MODE.
    leng = leng / 2.
    DO leng TIMES VARYING char1 FROM text(1)
                                NEXT text+2(1) RANGE text
                  VARYING char2 FROM text+1(1)
                                NEXT text+3(1) RANGE text.
      WRITE: char1, char2.
      char1 = 'x'.
      char2 = 'y'.
    ENDDO.
    DO 4 TIMES VARYING word FROM text-word1 NEXT text-word2.
      WRITE / word.
    ENDDO.
    DO.
      inc = sy-index  - 1.
      ASSIGN text-word1 INCREMENT inc TO <word> RANGE text.
      IF sy-subrc = 0.
        WRITE / <word>.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    Please assign  points.

  • Notes on examples related using of Field symbols

    Hi,
    I want some notes having examples of field symbols.
    Thanks & regards,
    Chetan

    I still don't follow what you are referring as Field Symbols.  If you talking about using Form variables dynamically in a query then check this thread 
    Variables in query ??
    Suda

  • Using of field-symbols iw32

    Hello to everyone!
    I've found in forum a special trick, wich in userexit for Headerdetails of servceorder give me information about position:
    data: element(50) type c,
    sresbd like resbd.
    field-symbols: <iresbd> type table.
    element = '(SAPLCOBC)RESB_BT[]'.
    assign (element) to <iresbd>.
    When I tried to debug I can read for example material number od the third position with
    <iresbd>[3]- matnr
    but in the program, after using this code I get the message that this field dosent exist.

    I still don't follow what you are referring as Field Symbols.  If you talking about using Form variables dynamically in a query then check this thread 
    Variables in query ??
    Suda

  • Modify DB by single field using Field Symbol

    Hi,
      please help me ,actually i have not use the field symbol in any object. i have one requirement ,i have to modify the DB by field STATUS using Field symbol ,
    I am sending u my code so please help me how can i modify DB using field symbol..
              gw_msg3_status1   = k_status1 .
              LOOP AT gi_msg3 INTO gs_msg3.
                gs_msg3-status  = gw_msg3_status1 .
                gs_msg3-issue   = lw_issuno.
           MODIFY gi_msg3 FROM gs_msg3 TRANSPORTING status.
                MODIFY gi_msg3 INDEX sy-tabix FROM gs_msg3 TRANSPORTING issue status.
              ENDLOOP.
    Thanks & Regards,
    Meenakshi

    perform dboperation_table using 'SET' 'BIRTHDT' '=' <fs>.
        perform dboperation_table using 'WHERE' 'PARTNER' '='  <fs>
        perform dboperation_update using 'BUT000'.
    form dboperation_table
    using p_type
          p_var1
          p_var2
          p_var3.
      data: t_l type cmst_str_data.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          clear t_l.
          if p_var3 is not initial.
            t_l = p_var3.
            condense t_l.
            concatenate '''' t_l '''' into t_l.
          endif.
          concatenate p_var1 p_var2 t_l into t_l
          separated by space.
          case p_type.
            when 'SET'.   append t_l to g_s_t.
            when 'WHERE'. append t_l to g_w_t.
          endcase.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_table
    form dboperation_update
    using  p_tabname type zdboperation-tabname.
      data: tabname type bus_table.
      data: d_cx_root            type ref to cx_root,
            d_text               type string.
      try.
          tabname-tabname = p_tabname.
          call function 'ZDBOPERATION_UPDATE'
            in update task
            exporting
              tabname     = tabname
            tables
              where_table = g_w_t
              set_table   = g_s_t.
        catch cx_root into d_cx_root.
          d_text = d_cx_root->get_text( ).
          message a398(00) with  d_text.
      endtry.
    endform.                    "DBOPERATION_update
    Hope it will help you.
    Regards,
    Madan.

  • Problem With Insert statement using field symbols with unicode enabled

    I was writng a function module for dyanamic operations on the table. We are using the field symbols, function module is unicode enabled.
    Assign statements are working fine, with which we created work are <fs_wa_header> and internal table <fs_tb_item> dynamically based on the table name (IM_TB_HENAME) which we get as import parameter.
    we have query which is giving us dump.
    INSERT  (IM_TB_HENAME)  FROM <FS_WA_HEADER>.

    Hi
    INSERT (IM_TB_HENAME) FROM <FS_WA_HEADER> is good for inserting a line in the database, so IM_TB_HENAME has to have the name of dictionary table.
    U should write:
    INSERT  <FS_WA_HEADER> INTO (IM_TB_HENAME).
    But I believe you can't use the variable IM_TB_HENAME, you should use another field-symbols:
    ASSIGN (IM_TB_HNAME) TO <FS_TB_ITEM>.
    INSERT  <FS_WA_HEADER> INTO <FS_TB_ITEM>.
    Max

  • How to use field symbols

    can anyone tell me how to use field symbols. What effect it has on performance of a program?
    what r its avantages?
    iam working on a report where iam facing a lot of problems in performance issue. can anyone tell how field symbols are useful in this regard?
    thanx to all

    Check the below links
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Additions
    1. ... STRUCTURE s DEFAULT wa
    2. ... TYPE t
    3. ... TYPE LINE OF t
    4. ... LIKE s
    5. ... LIKE LINE OF s
    Effect
    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.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT>.
    TABLES SFLIGHT.
    ASSIGN SFLIGHT-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... STRUCTURE s DEFAULT wa
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP/4 Dictionary ( s ). All fields of the structure can be addressed by name: <fs>-fieldname . The structured field symbol points initially to the work area wa specified after DEFAULT .
    The work area wa must be at least as long as the structure s . If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    Addition 2
    ... TYPE t
    Addition 3
    ... TYPE LINE OF t
    Addition 4
    ... LIKE s
    Addition 5
    ... LIKE LINE OF s
    Effect
    You can use additions 2 to 5 to type field symbols in the same way as FORM parameters (see also Type assignment of subroutine parameters). ASSIGN performs the same type checks as with USING parameters of FORM s.

  • How to use field symbol in select

    Hi,
        CONCATENATE 'WTG0' LV_MON INTO LV_FNAME.
        ASSIGN (LV_FNAME) TO <FS>.
        SELECT SINGLE <FS>  FROM COSP INTO LV_SAPRST
             WHERE OBJNR = LV_OBJ AND GJAHR = LV_YEAR AND WRTTP = '4' AND KSTAR = GT_INOUT-SAKNR
       Error message :    Unknown column name "<FS>" . field list. . field list. field list. 
       actually ,  if i use  if command,  i can do,  but i want to use simple code by fieldsymbol.
       is it possible in select command?
    Thanks in advance
    Benjamin

    Hi
    Hope it will help you.
    reward if help.
    Field Symbols
    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 symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    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.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    Related
    ASSIGN, DATA
    Additional help
    Declaring Field Symbols

  • How to use field-symbols in MODIFY ... TRANSPORTING and SORT

    Hi,
    I need to increase the performance of an abap report using the field-symbols. More exactly  the code is the following.
    TYPES:
      BEGIN OF itab_structure.
         INCLUDE STRUCTURE nameofstructure.
      TYPES:
         RECNO   LIKE sy-tabix,
      END OF itab_structure.
    DATA:
      itab TYPE STANDARD TABLE OF  itab_structure
           WITH HEADER LINE
           WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    SORT itab ASCENDING BY f1.
    LOOP AT itab WHERE f1 = '10'.
        itab-fn= value-n.
    MODIFY itab
                 TRANSPORTING  fx fy fz ft     
                        WHERE  f1   = c1_filed AND
                                      f2   = c2_field.
    ENDLOOP.
    I need your suggestions in this kind of conversion or solution.
    SORT itab ASCENDING BY f1 (<-- I don't know if in this case the better performances should be obtained using field symbols and in which way)
    FIELD-SYMBOLS: <fs_itab_line> TYPE LINE OF itab.
    LOOP AT itab ASSIGNING <fs_itab_line> WHERE
    <fs_itab_line>-f1 = '10'.
    MODIFY itab 
                 TRANSPORTING  fx fy fz ft     
                        WHERE  f1   = c1_filed AND
                                      f2   = c2_field.
    (I don't know if in this case the better performances should be obtained using field symbols and in which way)
    ENDLOOP.
    I wish to implement the field symbols or the better performance in terms of execution time in all my abap code, where it is possible.
    Any suggestion will be well appreciated.
    Thanks in advance for your kind support.
    Regards,
           Giovanni

    Dear All,
    I have appeciated your suggestions and I can conclude these points in my case:
    1) The "sort" statement is not optimized in a different way using filed-symbols
    2) The loop with "where" condition on a standard table is performed using filed-symbols
    But ... my last point to investigate is about the statement MODIFY table TRANSPORTING f1, f2 WHERE conditions.
    More exactly, in my code the execution logic of the abap code expects a global modification of the same table at the end of every (primary) loop, using the MODYFY statement.
    In other words in my code I can locate two loops on the same table in the following logic:
    LOOP AT table1 WHERE f1 = '10'. (#1)
          updates to table1
          set c1_filed, c2_filed
          LOOP AT table1.   (#2)            
             IF f1 = c1_filed AND
                f2 = c2_filed.
               table1-fx = 'x'.
               table1-fy = 'y'.
               table1-fz = 'z'.
               table1-ft = 't'.   
             ENDIF.                 
             MODIFY table1.            
          ENDLOOP.   (#2)              
    ENDLOOP.   (#1)
    In better way (maybe more fast in terms of execution time) to modify a set of lines (MODIFY...TRANSPORTING...WHERE):
    LOOP AT table1 WHERE f1 = '10'.
       table1-fx= 'x'.
       table1-fy= 'y'.
       table1-fz= 'z'.
       table1-ft= 't'.
       MODIFY itab
          TRANSPORTING fx fy fz ft
       WHERE f1 = c1_filed AND
             f2 = c2_field.
    ENDLOOP.
    My aim is to use field-symbols everywhere possible for speeding up the execution of my code,by maintaining this logic.
    My proposal should be the following but I need your kind opinion.
    FIELD-SYMBOLS: <fs_#1_line> TYPE LINE OF table1.
    FIELD-SYMBOLS: <fs_#2_line> TYPE LINE OF table1.
    LOOP AT table1 WHERE f1 = '10' ASSIGNING <fs_#1_line>. (#1)
          updates to table1
          set c1_filed, c2_filed
          LOOP AT table1 ASSIGNING <fs_#2_line>.  (#2)            
             IF <fs_#2_line>-f1 = c1_filed AND
                <fs_#2_line>-f2 = c2_filed.
               <fs_#2_line>-fx = 'x'.
               <fs_#2_line>-fy = 'y'.
               <fs_#2_line>-fz = 'z'.
               <fs_#2_line>-ft = 't'.   
             ENDIF.                 
          ENDLOOP.   (#2)              
    ENDLOOP.   (#1)
    Your kind support is very important for me.
    Thanks in advance.
    Regards,
         Giovanni

  • How to use field symbols in program

    how to use field symbols can any one explain with example please..
    Regards,
    venki...

    Hi
    Field Symbols
    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 symbols are similar to dereferenced pointers in C (that is, pointers to which the content operator * is applied). However, the only real equivalent of pointers in ABAP, that is, variables that contain a memory address (reference) and that can be used without the contents operator, are reference variables in ABAP Objects.
    All operations programmed with field symbols are applied to the field assigned to it. For example, a MOVE statement between two field symbols moves the contents of the field assigned to the first field symbol to the field assigned to the second field symbol. The field symbols themselves point to the same fields after the MOVE statement as they did before.
    You can create field symbols either without or with type specifications. If you do not specify a type, the field symbol inherits all of the technical attributes of the field assigned to it. If you do specify a type, the system checks the compatibility of the field symbol and the field you are assigning to it during the ASSIGN statement.
    Field symbols provide greater flexibility when you address data objects:
    If you want to process sections of fields, you can specify the offset and length of the field dynamically.
    You can assign one field symbol to another, which allows you to address parts of fields.
    Assignments to field symbols may extend beyond field boundaries. This allows you to address regular sequences of fields in memory efficiently.
    You can also force a field symbol to take different technical attributes from those of the field assigned to it.
    The flexibility of field symbols provides elegant solutions to certain problems. On the other hand, it does mean that errors can easily occur. Since fields are not assigned to field symbols until runtime, the effectiveness of syntax and security checks is very limited for operations involving field symbols. This can lead to runtime errors or incorrect data assignments.
    While runtime errors indicate an obvious problem, incorrect data assignments are dangerous because they can be very difficult to detect. For this reason, you should only use field symbols if you cannot achieve the same result using other ABAP statements.
    For example, you may want to process part of a string where the offset and length depend on the contents of the field. You could use field symbols in this case. However, since the MOVE statement also supports variable offset and length specifications, you should use it instead. The MOVE statement (with your own auxiliary variables if required) is much safer than using field symbols, since it cannot address memory beyond the boundary of a field. However, field symbols may improve performance in some cases.
    check the below links u will get the answers for your questions
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/field_sy.htm
    http://searchsap.techtarget.com/tip/1,289483,sid21_gci920484,00.html
    Syntax Diagram
    FIELD-SYMBOLS
    Basic form
    FIELD-SYMBOLS <fs>.
    Extras:
    1. ... TYPE type
    2. ... TYPE REF TO cif
    3. ... TYPE REF TO DATA
    4. ... TYPE LINE OF type
    5. ... LIKE s
    6. ... LIKE LINE OF s
    7. ... TYPE tabkind
    8. ... STRUCTURE s DEFAULT wa
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Cannot Use Untyped Field Symbols ad Cannot Use Field Symbols as Components of Classes.
    Effect
    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.
    You can only use one of the additions.
    Example
    Output aircraft type from the table SFLIGHT using a field symbol:
    FIELD-SYMBOLS <PT> TYPE ANY.
    DATA SFLIGHT_WA TYPE SFLIGHT.
    ASSIGN SFLIGHT_WA-PLANETYPE TO <PT>.
    WRITE <PT>.
    Addition 1
    ... TYPE type
    Addition 2
    ... TYPE REF TO cif
    Addition 3
    ... TYPE REF TO DATA
    Addition 4
    ... TYPE LINE OF type
    Addition 5
    ... LIKE s
    Addition 6
    ... LIKE LINE OF s
    Addition 7
    ... TYPE tabkind
    Effect
    You can define the type of the field symbol using additions 2 to 7 (just as you can for FORM parameters (compare Defining the Type of Subroutine Parameters). When you use the ASSIGN statement, the system carries out the same type checks as for USING parameters of FORMs.
    This addition is not allowed in an ABAP Objects context. See Cannot Use Obsolete Casting for FIELD SYMBOLS.
    In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs. See Defining Types Using STRUCTURE.
    Effect
    Assigns any (internal) field string or structure to the field symbol from the ABAP Dictionary (s). All fields of the structure can be addressed by name: <fs>-fieldname. The structured field symbol points initially to the work area wa specified after DEFAULT.
    The work area wa must be at least as long as the structure s. If s contains fields of the type I or F, wa should have the structure s or at least begin in that way, since otherwise alignment problems may occur.
    Example
    Address components of the flight bookings table SBOOK using a field symbol:
    DATA SBOOK_WA LIKE SBOOK.
    FIELD-SYMBOLS <SB> STRUCTURE SBOOK
    DEFAULT SBOOK_WA.
    WRITE: <SB>-BOOKID, <SB>-FLDATE.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • How to use Field-symbol with dynamic select query

    Can anybody tell me, how to use field-symbols in the dynamic select query.

    FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
    1. ... typing
    2. ... STRUCTURE struc DEFAULT dobj
    The FIELD-SYMBOLS statement declares a field symbol <fs>. The name conventions apply to the name fs. The angle brackets of the field symbols indicate the difference to data objects and are obligatory. You can declare field symbols in any procedure and in the global declaration section of an ABAP program, but not in the declaration section of a class or an interface. You can use a field symbol in any operand position in which it is visible and which match the typing defined using typing.
    After its declaration, a field symbol is initial - that is, it does not reference a memory area. You have to assign a memory area to it (normally using the ASSIGN statement) before you can use it as an operand. Otherwise an exception will be triggered.
    eg.
    FIELD-SYMBOLS <fs> TYPE ANY.
    DATA: BEGIN OF line,
            string1(10) VALUE '0123456789',
            string2(10) VALUE 'abcdefghij',
          END OF line.
    WRITE / line-string1+5.
    ASSIGN line-string1+5(*) TO <fs>.
    WRITE / <fs>.
    output:
    56789
    56789
    reward if helpful
    anju

Maybe you are looking for

  • How to get the list of  Quotations...???

    Hi MM Gurus, How to get the list of Used Quotations & Non Used Quotations. i am not talking about Open quotation ,closed quotation.. if once i created PO through quotation it should be used quotation. i not created PO through quotation it s should be

  • Issue creating a database: SGA_MAX_SIZE and SGA_TARGET

    Hello: While creating a custom database, I am running into issues with the values I specify for SGA_MAX_SIZE and SGA_TARGET. The install manual for the product I am creating the database for says that SGA_MAX_SIZE should be >= SGA_TARGET_SIZE. It als

  • BW Statistics queries

    Dear all, I am Viswanath.  I had activated all business content objects related to BW Statistics.  Here i have selected Data Flow Before and AFterwards.  My problem is that i am not able to see any queries under the respective cubes in BEx.  Can anyo

  • Forgot my Nokia c3-00 security code

    Hy i have forgotten my nokia c3 security code i have tried everything like 12345 1234 5555 0000 they all dnt work i have also try the master security code that i got online it doesnt work....pliz help me. Moderator's Note: We have removed personal in

  • Looking for online php book(s)

    heya, im looking for an online php book. the more the better. any suggestions/links? thanks in advance.