Can limit loop on FIELD-SYMBOLS list ?

i have loop ....
  LOOP AT <GT_TABLE> ASSIGNING <DYN_TABLE1> .
i want to do
LOOP AT <GT_TABLE> ASSIGNING <DYN_TABLE1> where
but i get message that the 'LOOP .. WHERE'
Have to be statically define

hi Dakota,
the WHERE won't work here. The reason is the actual structure of <DY_TABLE1> only determined at runtime.
The workaround is that when you are in the LOOP already, you have to ASSIGN fields of the dynamic structure (ASSIGN COMPONENT ...) than you can decide if you need that record or not, if not than CONTINUE...
hope this helps
ec

Similar Messages

  • Loop at  field-symbol  (any table) into string ?

    Hi Everyone,
    I need little help, I have a requirement to extract table content with columns names as the header.
    After doing some search I figured out the best way to this since table name will be only avaialbe at runtime through
    a selection field . my problem is to loop through field-symbol and convert a structure to string value so that I can
    write to the file.
    REPORT  zlab_tbl_export.
    DATA table_name(30) VALUE 'ZSMARTTS_HTML'.
    DATA v_file(100) VALUE 'c:\sap_export.txt'.
    DATA line(1000).
    DATA: o_data TYPE REF TO data.
    CREATE DATA o_data TYPE TABLE OF (table_name).
    FIELD-SYMBOLS: <table> TYPE ANY TABLE.
    ASSIGN o_data->* TO <table>.
    SELECT * UP TO 100 ROWS FROM (table_name) INTO TABLE <table>.
    OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    >>>>>>> LOOP at <table> into line.   >>>>>>>>>>>>  " Here the code breaks and fail
      TRANSFER line to v_file. 
      WRITE :/ line.          
    ENDLOOP.
    CLOSE DATASET v_file.
    Exception Message
    |Error analysis                                                                                |
    |    You attempted to move one data object to another.                                             |
    |    This is not possible here because the conversion of a data object                             |
    |    of type "v" to type "C" is not supported.                                                     |
    |                                                                                |
    |      List of internal ABAP types:                                                                |
    |                                                                                |
    |      C    Text (Character)                                                                       |
    |      N    Numerical text                                                                         |
    |      D    Date (YYYYMMDD)                                                                        |
    |      T    Time (HHMMSS)                                                                          |
    |      X    Hexadecimal                                                                            |
    |      I    Integer                                                                                |
    |      P    Packed number                                                                          |
    |      F    Floating point number                                                                  |
    |                                                                                |
    |      h    Internal table                                                                         |
    |      r    Object reference                                                                       |
    |      l    Data reference                                                                         |
    |      g    String of type C                                                                       |
    |      y    String of type X                                                                       |
    |      s    2-byte integer with plus/minus sign                                                    |
    |      b    1-byte integer without plus/minus sign                                                 |
    |      u    Structure (flat structure)                                                             |
    |      v    Structure (deep structure)                                                             |

    Hi Everyone, I need little help, I have a requirement to extract table content with columns names as the header. After doing some search I figured out the best way to this since table name will be only avaialbe at runtime through a selection field . my problem is to loop through field-symbol and convert a structure to string value so that I can write to the file.
    thie is the code
    REPORT  zlab_tbl_export.
    DATA table_name(30) VALUE 'ZSMARTTS_HTML'.
    DATA v_file(100) VALUE 'c:\sap_export.txt'.
    DATA line(1000).
    DATA: o_data TYPE REF TO data.
    CREATE DATA o_data TYPE TABLE OF (table_name).
    FIELD-SYMBOLS: <table> TYPE ANY TABLE.
    ASSIGN o_data->* TO <table>.
    SELECT * UP TO 100 ROWS FROM (table_name) INTO TABLE <table>.
    OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP at <table> into line.   " Fail here
      TRANSFER line to v_file. 
      WRITE :/ line.           
    ENDLOOP.
    CLOSE DATASET v_file.
    and this is the exception:
    Error analysis                                                                               
    You attempted to move one data object to another.                                            
        This is not possible here because the conversion of a data object                            
        of type v to type C is not supported.                                                    
    Edited by: Misbah on Jan 7, 2010 11:50 PM

  • Can I verify a field-symbol using its component name?

    Hello experts,
    I am looping at my field-symbol and I need to know what are its component name.
    I need to create an IF or CASE statement checking whether the field-symbol's
    component name is equal to that of the value that I declared. I want to do
    something like this:
    LOOP AT <fs_dyntable> ASSIGNING <wa_dyntable>.
    ASSIGN COMPONENT sy-index OF STRUCTURE <wa_dyntable>
            TO <component>.
            IF sy-subrc <> 0.
              EXIT.
            ENDIF.
    if component name = '2000'.
        condition...
      elseif component name = '1999'.
        condition...
      elseif component name = '1998'.
        condition...
      endif.
    endloop.
    Again, thank you guys and take care!

    Hi,
    I am not clear on your doubt , but you can use field-symbol fields like below:
    * if <component>-fld1 = '2000'.
    condition...
    elseif <component>-fld1 = '1999'.
    condition...
    elseif <component>-fld1 = '1998'.
    condition...
    endif.
    endloop.
    LOOP AT x_table ASSIGNING <wa_table>.
    IF <wa_table>-fld1 EQ 100.
    -----your code
    ENDIF.
    ENDLOOP.
    Regards
    Appana

  • 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.

  • Looping a Field symbol.

    Hi,
    Can someone explain what to me what the following statement means?
    Data: i_tab  TYPE STANDARD TABLE.
    I looked it up and and it says that it is an ABAP built in type which is generic, but i fail to understand its usage.
    And here is my scenario.
    Field-symbols: <IT_DETAILS >  TYPE STANDARD TABLE,
                          <lines>                TYPE  (Transparent dictionary table)
    LOOP AT <lt_details> ASSIGNING <lines>.
    move <lines>-field to l_variable.
    Endloop
    Upon execution, I get a dump at the Loop statement saying that there is an 'ASSIGN_TYPE_CONFLICT'.You attempted to assign a field to a typed field symbol,but the field does not have the required type.
    How to correct the error
        Adapt the type of the field symbol to the type of the field or use an
        untyped field symbol or use the "CASTING" addition.
    Can someone explain the correct way to type the field symbol and implement the loop construct?
    Any help will be highly appreciated

    Hello,
    Can you tell us the type of the variable l_variable?
    Example:
    FIELD-SYMBOLS:    <pos_data> TYPE ANY,
                                   <gt_pos_data>  TYPE table.
      DATA : lt_csks LIKE gt_csks WITH HEADER LINE.
    LOOP AT <gt_pos_data> ASSIGNING <pos_data>.
        MOVE-CORRESPONDING <pos_data> TO lt_csks.
      ENDLOOP.

  • Looping the field symbol

    Hi friends,
      I have to populate(Display) the data using field symol.
    I am providing my code:
    data: o_ref type ref to data.
    field-symbols: <Lt_table> type standard table.
    parameters: p_tab type tabname.
    start-of-selection.
    create data o_ref type table of (p_tab).
    assign o_ref->* to <lt_table>.
    select * into table <lt_table> from (p_tab).
    I am unable to papulate the data.please help me out.
    thanks,
    satya

    REPORT z_dynamic.
    TYPE-POOLS : abap.
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa>,
                   <dyn_field>.
    DATA: dy_table TYPE REF TO data,
          dy_line  TYPE REF TO data,
          xfc TYPE lvc_s_fcat,
          ifc TYPE lvc_t_fcat.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      PERFORM get_structure.
      PERFORM create_dynamic_itab.
      PERFORM get_data.
      PERFORM write_out.
    *       FORM get_structure                                            *
    FORM get_structure.
      DATA : idetails TYPE abap_compdescr_tab,
             xdetails TYPE abap_compdescr.
      DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
    * Get the structure of the table.
      ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( p_table ).
      idetails[] = ref_table_des->components[].
      LOOP AT idetails INTO xdetails.
        CLEAR xfc.
        xfc-fieldname = xdetails-name .
        xfc-datatype = xdetails-type_kind.
        xfc-inttype = xdetails-type_kind.
        xfc-intlen = xdetails-length.
        xfc-decimals = xdetails-decimals.
        APPEND xfc TO ifc.
      ENDLOOP.
    ENDFORM.
    *       FORM create_dynamic_itab                                      *
    FORM create_dynamic_itab.
    * Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
                   EXPORTING
                      it_fieldcatalog = ifc
                   IMPORTING
                      ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    * Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    ENDFORM.
    *       FORM get_data                                                 *
    FORM get_data.
    * Select Data from table.
      SELECT * INTO TABLE <dyn_table>
                 FROM (p_table).
    ENDFORM.
    *       FORM write_out                                                *
    FORM write_out.
    * Write out data from table.
      LOOP AT <dyn_table> INTO <dyn_wa>.
        DO.
          ASSIGN COMPONENT  sy-index
             OF STRUCTURE <dyn_wa> TO <dyn_field>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          IF sy-index = 1.
            WRITE:/ <dyn_field>.
          ELSE.
            WRITE: <dyn_field>.
          ENDIF.
        ENDDO.
      ENDLOOP.
    ENDFORM.

  • Field symbols in loop

    Hi,
    I need to change this code using Field symbols. Can anybody help me?
      DATA: i_history  TYPE STANDARD TABLE OF mmreq_history INITIAL SIZE 0,
            wa_history TYPE mmreq_history,
            l_menge    LIKE eban-menge.
        LOOP AT i_history INTO wa_history.
          IF wa_history-bstyp EQ dc_plan.
            ADD wa_history-menge TO l_menge.
          ELSEIF wa_history-bstyp EQ dc_abierto.
            CLEAR: wa_history-menge, wa_history-meins.
            SELECT SINGLE ktmng meins
              FROM ekpo
              INTO (wa_history-menge, wa_history-meins)
              WHERE ebeln EQ wa_history-ebeln
                AND ebelp EQ wa_history-ebelp.
            MODIFY i_history FROM wa_history.
            ADD wa_history-menge TO l_menge.
          ENDIF.
        ENDLOOP.
    Thanks!!!
    Carles

    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 CAN I SEND FIELD SYMBOL TO SUBROUTINE

    HAI,
             HOW CAN I SEND FIELD SYMBOL TO SUBROUTINE
             HOW CAN I COME BACK FROM 5TH INTERACTIVE REROT TO 2ND
    INTERACTIVE REPORT.
    THANK YOU.
    ASHOK

    Hi
    Write some code in the program to come to 2nd list from 5th list
    if sy-lsind = 5.
       sy-lsind = 2.
    endif.
    for field symbols see the doc
    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
    Reward points if useful
    Regards
    Anji

  • Can any one explain me about Field symbols in Genral Reports?

    Can any one explain me about Field symbols in Genral Reports?
    If possible, plz explain me with the code to explain me about the field symbols.
    Regards,
    Krishna Chaitanya

    Syntax
    FIELD-SYMBOLS <fs> { typing | STRUCTURE struc DEFAULT dobj }.
    Extras:
    1. ... typing
    2. ... STRUCTURE struc DEFAULT dobj
    Effect
    The FIELD-SYMBOLS statement declares a field symbol <fs>. The naming 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.
    Addition 1
    ... typing
    Effect
    You can use the addition typing to type the field symbol. The syntax of typing is described under Syntax of Typing. The typing specifies which memory areas can be assigned to the field symbol (see Checking the Typing) and in which operand positions it can be used.
    Note
    You can omit the addition typing outside of methods. In this case, the field symbol has the complete generic type any and is implicitly assigned the predefined constant space during the declaration.
    Addition 2
    ... STRUCTURE struc DEFAULT dobj
    Effect
    If you specify the addition STRUCTURE instead of typing for a field symbol, and struc is a local program structure (a data object, not a data type) or a flat structure from the ABAP Dictionary, this structure is cast for the field symbol <fs>. You have to specify a data object dobj that is initially assigned to the field symbol.
    The field symbol copies the technical attributes of structure struc as if it were completely typed. When you assign a data object using the addition DEFAULT, or later using ASSIGN, its complete data type is not checked in non- Unicode programs. Instead, the system merely checks whether it has at least the length of the structure and its alignment.
    In Unicode programs, we differentiate between structured and elementary data objects. For a structured data object dobj, its Unicode fragment view has to match the one of struc. In the case of an elementary data object, the object must be character-type and flat, and struc must be purely character-type. The same applies to assignments of data objects to field symbols typed using STRUCTURE when using the ASSIGN statement.
    Note
    Field symbols declared using the addition STRUCTURE are a mixture of typed field symbols and a utility for casting structured data types. You should use the additions TYPE or LIKE for the FIELD-SYMBOLS statement to type field symbols, while the addition CASTING of the ASSIGN statement is used for casting.
    Example
    The first example shows the obsolete usage of the addition STRUCTURE.
    DATA wa1 TYPE c LENGTH 512.
    FIELD-SYMBOLS <scarr1> STRUCTURE scarr DEFAULT wa1.
    <scarr1>-carrid = '...'.
    The second example shows the replacement of STRUCTURE with the additions TYPE and CASTING.
    DATA wa2 TYPE c LENGTH 512.
    FIELD-SYMBOLS <scarr2> TYPE scarr.
    ASSIGN wa2 TO <scarr2> CASTING.
    <scarr2>-carrid = '...'.
    Also,
    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

  • Field Symbols, Field String, and Field Group.

    Hi,
    Can you differentiate between filed symbols, field strings and field groups,
    With regards,
    Bharath Mohan B

    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.
    Related
    ASSIGN, DATA
    Additional help
    Declaring Field Symbols
    FIELD GROUPS
    are used to hold/handle large amount of data when the internal table are not useful
    we use EXTRACT statement, HEADER structure in them
    see the example
    REPORT demo_extract.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    START-OF-SELECTION.
      INSERT: spfli-carrid spfli-connid sflight-fldate
                INTO header,
              spfli-cityfrom spfli-cityto
                INTO flight_info.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    END-OF-SELECTION.
      SORT STABLE.
      LOOP.
        AT FIRST.
          WRITE / 'Flight list'.
          ULINE.
        ENDAT.
        AT flight_info WITH flight_date.
          WRITE: / spfli-carrid , spfli-connid, sflight-fldate,
                   spfli-cityfrom, spfli-cityto.
        ENDAT.
        AT flight_date.
          WRITE: / spfli-carrid , spfli-connid, sflight-fldate.
        ENDAT.
        AT LAST.
          ULINE.
          WRITE: cnt(spfli-carrid), 'Airlines'.
          ULINE.
        ENDAT.
      ENDLOOP.
    FIELD STRING is nothing but a string with  one row of records.
    Reward points if useful
    regards
    Anji

  • What is field symbols?

    Hi all,
    Can anyone explains what is Fiels symbol and significance of that with examples?
    Thanks
    Shiva

    HI Shiva
    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. (For more information, see Data References).
    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
    To declare a field symbol, use the statement
    FIELD-SYMBOLS <FS> [<type>|STRUCTURE <s> DEFAULT <wa>].
    For field symbols, the angle brackets are part of the syntax. They identify field symbols in the program code.
    If you do not specify any additions, the field symbol <FS> can have data objects of any type assigned to it. When you assign a data object, the field symbol inherits its technical attributes. The data type of the assigned data object becomes the actual data type of the field symbol.
    Note: it is possible to assign reference variables and structured data objects to untyped field symbols. However, the static field symbol is only a pointer to the field in memory, and does not have the complex type attributes of a reference or structured field until runtime. You can only use the field symbol to address the whole field (for example, in a MOVE statement). Specific statements such as CREATE OBJECT <FS> or LOOP AT <FS> are not possible.
    Typing Field Symbols
    The <type> addition allows you to specify the type of a field symbol. When you assign a data object to a field symbol, the system checks whether the type of the data object you are trying to assign is compatible with that of the field symbol. If the types are not compatible or convertible, the system reacts with a syntax or runtime error. If however, you want to assign the type of the field symbol to the data object by means of casting, you must do so explicitly using the ASSIGN statement. The system then treats the assigned data object as if it had the same type as the field symbol.
    You specify the type of a field symbol using the same semantics as for formal parameters in procedures. For <type> you can enter either TYPE <t> or LIKE <f>. You can specify the type either generically or in full. If you specify a generic type, the type of the field symbol is either partially specified or not specified at all. Any attributes that are not specified are inherited from the corresponding data object in the ASSIGN statement. If you specify the type fully, all of the technical attributes of the field symbol are determined when you define it. You can then only assign data objects to it that have exactly the same data type.
    You should always specify a type for each field symbol. If you cannot avoid defining a generic field symbol, make this clear by using an appropriate generic type declaration.
    Generic Type Specification
    The following types allow you more freedom when using actual parameters. The data object only needs to have the selection of attributes specified.
    Typing
    Check for data object
    No type specification
    TYPE ANY
    All types of data object are accepted. The field symbol adopts all of the attributes of the data object.
    TYPE C, N, P, or X
    Only data objects with type C, N, P, or X are accepted. The field symbol adopts the field length and DECIMALS specification (type P) of the data object.
    TYPE TABLE
    The system checks whether the data object is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE
    The system checks whether the data object is an internal table. The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE INDEX TABLE
    The system checks whether the data object is an index table (standard or sorted table). The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE STANDARD TABLE
    The system checks whether the data object is a standard internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE SORTED TABLE
    The system checks whether the actual parameter is a sorted internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE HASHED TABLE
    The system checks whether the actual parameter is a hashed internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    If you specify a type generically, remember that the attributes inherited by the field symbol from the program are not statically recognizable in the program. You can, at most, address them dynamically.
    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.
    If you adopt a structured type generically (a structure, or a table with structured line type), the individual components cannot be addressed in the program either statically or dynamically. In this case, you would have to work with further field symbols and the method of assigning structures component by component.
    Specifying the Type Fully
    When you use the following types, the technical attributes of the field symbols are fully specified. The technical attributes of the data objects must correspond to those of the field symbol.
    Typing
    Technical attributes of the field symbol
    TYPE D, F, I, or T
    The field symbol has the technical attributes of the predefined elementary type
    TYPE <type>
    The field symbol has the type <type>. This is a data type defined within the program using the TYPES statement, or a type from the ABAP Dictionary
    TYPE REF TO <cif>|DATA
    The field symbol is a reference variable for the class or interface <cif>, or for a data object.
    TYPE LINE OF <itab>
    The field symbol has the same type as a line of the internal table <itab> defined using a TYPES statement or defined in the ABAP Dictionary
    LIKE <f>
    The field symbol has the same type as an internal data object <f> or structure, or a database table from the ABAP Dictionary
    When you use a field symbol that is fully typed, you can address its attributes statically in the program, since they are recognized in the source code. If you fully specify the type of a field symbol as a reference or structured data object, you can address it as you would the data object itself, once you have assigned an object to it. So, for example, you could address the components of a structure, loop through an internal table, or create an object with reference to a field symbol.
    REPORT demo_field_symbols_type .
    DATA: BEGIN OF line,
             col1(1) TYPE c,
             col2(1) TYPE c VALUE 'X',
           END OF line.
    FIELD-SYMBOLS <fs> LIKE line.
    ASSIGN line TO <fs>.
    MOVE <fs>-col2 TO <fs>-col1.
    The field symbol <FS> is fully typed as a structure, and you can address its components in the program.
    Attaching a structure to a field symbol
    The STRUCTURE addition forces a structured view of the data objects that you assign to a field symbol.
    FIELD-SYMBOLS <FS> STRUCTURE <s> DEFAULT <f>.
    The structure <s> is either a structured local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a data object that must be assigned to the field symbol as a starting field. However, this assignment can be changed later using the ASSIGN statement.
    When you assign a data object to the field symbol, the system only checks that it is at least as long as the structure. You can address the individual components of the field symbol. It has the same technical attributes as the structure <s>.
    If <s> contains components with type I or F, you should remember the possible effects of alignment. When you assign a data object to a field symbol with a structure, the data object must have the same alignment, otherwise a runtime error may result. In such cases, you are advised to assign such data objects only to structured field symbols, which retain the same structure as the field symbol at least over the length of the structure.
    The STRUCTURE is obsolete; you should no longer use it. Field symbols defined using the STRUCTURE addition are a mixture of typed field symbols and a utility for casting to either local or ABAP Dictionary data types. If you want to define the type of a field symbol, include the TYPE addition in a FIELD-SYMBOLS statement. If you want to use casting, include the CASTING addition in an ASSIGN statement.
    Example using the obsolete STRUCTURE addition:
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             col1(2),
             col2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
                   <f2> STRUCTURE line2 DEFAULT wa.
    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
           / <f2>-col1, <f2>-col2.
    Example using the correct syntax (TYPE and CASTING):
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             COL1(2),
             COL2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> LIKE line1.
    ASSIGN wa TO <f1> CASTING.
    FIELD-SYMBOLS: <f2> LIKE line2.
    ASSIGN wa TO <f2> CASTING.
    WRITE: / <f1>-col1, <F1>-col2, <F1>-col3,
           / <f2>-col1, <F2>-col2.
    In both cases, the list appears as follows:
    012 34 56789
    01 2345/67/89
    This example declares two field symbols to which different structures are attached. The string WA is then assigned to each of them. The output shows that the field symbols assign the strings component by component according to the type of the components.
    Assigning Components of Structures to a Field Symbol
    For a structured data object <s>, you can use the statement
    ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.
    to assign one of its components <comp> to the field symbol <FS>. You can specify the component <comp> either as a literal or a variable. If <comp> is of type C or a structure that has no internal tables as components, it specifies the name of the component. If <comp> has any other elementary data type, it is converted to type I and specifies the number of the component. If the assignment is successful, SY-SUBRC is set to 0. Otherwise, it is set to 4.
    This statement is particularly important for addressing components of structured data objects dynamically. If you assign a data object to a field symbol either generically or using casting, or pass it generically (or using casting) to the parameter interface of a procedure, you cannot address its components either statically or dynamically. Instead, you must use the above statement. This allows indirect access either using the component name or its index number.
    DATA: BEGIN OF LINE,
            COL1 TYPE I VALUE '11',
            COL2 TYPE I VALUE '22',
            COL3 TYPE I VALUE '33',
          END OF LINE.
    DATA COMP(5) VALUE 'COL3'.
    FIELD-SYMBOLS: <F1>, <F2>, <F3>.
    ASSIGN LINE TO <F1>.
    ASSIGN COMP TO <F2>.
    DO 3 TIMES.
      ASSIGN COMPONENT SY-INDEX OF STRUCTURE <F1> TO <F3>.
      WRITE <F3>.
    ENDDO.
    ASSIGN COMPONENT <F2> OF STRUCTURE <F1> TO <F3>.
    WRITE / <F3>.
    The output is:
    11         22         33
    33
    The field symbol <F1> points to the structure LINE, <F2> points to the field COMP. In the DO loop, the components of LINE are specified by their numbers and assigned one by one to <F3>. After the loop, the component COL3 of LINE is specified by its name and assigned to <F3>. Note that ASSIGN COMPONENT is the only possible method of addressing the components of <F1>. Expressions such as <F1>-COL1 are syntactically incorrect.
    Regards,
    Laxmi.

  • Dynamic field symbol

    Hello :i would like to ask one favor , how can i define a field symbol, that can recieve a dynamic variable
    segment of code:
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = it_dynamic.
      ASSIGN it_dynamic->* TO <dyn_table>.
    CREATE DATA wa_dynamic LIKE line of <dyn_table>.
      ASSIGN wa_dynamic->* TO <dyn_wa>. " this one 'wa_dynamic'  i need to sent to <dyn_wa>
    thanks a lot

    HI
    GOOD
    Generic Type Specification
    The following types allow you more freedom when using actual parameters. The data object only needs to have the selection of attributes specified.
    Typing
    Check for data object
    No type specification
    TYPE ANY
    All types of data object are accepted. The field symbol adopts all of the attributes of the data object.
    TYPE C, N, P, or X
    Only data objects with type C, N, P, or X are accepted. The field symbol adopts the field length and DECIMALS specification (type P) of the data object.
    TYPE TABLE
    The system checks whether the data object is a standard internal table. This is a shortened form of TYPE STANDARD TABLE (see below).
    TYPE ANY TABLE
    The system checks whether the data object is an internal table. The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE INDEX TABLE
    The system checks whether the data object is an index table (standard or sorted table). The field symbol inherits all of the attributes (line type, table type, key) from the data object.
    TYPE STANDARD TABLE
    The system checks whether the data object is a standard internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE SORTED TABLE
    The system checks whether the actual parameter is a sorted internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    TYPE HASHED TABLE
    The system checks whether the actual parameter is a hashed internal table. The field symbol inherits all of the remaining attributes (line type, key) from the data object.
    If you specify a type generically, remember that the attributes inherited by the field symbol from the program are not statically recognizable in the program. You can, at most, address them dynamically.
    TYPES: BEGIN OF line,
             col1 TYPE c,
             col2 TYPE c,
           END OF line.
    DATA: wa TYPE line,
          itab TYPE HASHED TABLE OF line WITH UNIQUE KEY col1,
          key(4) TYPE c VALUE 'COL1'.
    FIELD-SYMBOLS <fs> TYPE ANY TABLE.
    ASSIGN itab TO <fs>.
    READ TABLE <fs> WITH TABLE KEY (key) = 'X' INTO wa.
    The internal table ITAB is assigned to the generic field symbol <FS>, after which it is possible to address the table key of the field symbol dynamically. However, the static address
    READ TABLE <fs> WITH TABLE KEY col1 = 'X' INTO wa.
    is not possible syntactically, since the field symbol does not adopt the key of table ITAB until runtime. In the program, the type specification ANY TABLE only indicates that <FS> is a table. If the type had been ANY (or no type had been specified at all), even the specific internal table statement READ TABLE <FS> would not have been possible.
    If you adopt a structured type generically (a structure, or a table with structured line type), the individual components cannot be addressed in the program either statically or dynamically. In this case, you would have to work with further field symbols and the method of assigning structures component by component.
    Specifying the Type Fully
    When you use the following types, the technical attributes of the field symbols are fully specified. The technical attributes of the data objects must correspond to those of the field symbol.
    Typing
    Technical attributes of the field symbol
    TYPE D, F, I, or T
    The field symbol has the technical attributes of the predefined elementary type
    TYPE <type>
    The field symbol has the type <type>. This is a data type defined within the program using the TYPES statement, or a type from the ABAP Dictionary
    TYPE REF TO <cif>|DATA
    The field symbol is a reference variable for the class or interface <cif>, or for a data object.
    TYPE LINE OF <itab>
    The field symbol has the same type as a line of the internal table <itab> defined using a TYPES statement or defined in the ABAP Dictionary
    LIKE <f>
    The field symbol has the same type as an internal data object <f> or structure, or a database table from the ABAP Dictionary
    When you use a field symbol that is fully typed, you can address its attributes statically in the program, since they are recognized in the source code. If you fully specify the type of a field symbol as a reference or structured data object, you can address it as you would the data object itself, once you have assigned an object to it. So, for example, you could address the components of a structure, loop through an internal table, or create an object with reference to a field symbol.
    REPORT demo_field_symbols_type .
    DATA: BEGIN OF line,
             col1(1) TYPE c,
             col2(1) TYPE c VALUE 'X',
           END OF line.
    FIELD-SYMBOLS <fs> LIKE line.
    ASSIGN line TO <fs>.
    MOVE <fs>-col2 TO <fs>-col1.
    The field symbol <FS> is fully typed as a structure, and you can address its components in the program.
    Attaching a structure to a field symbol
    The STRUCTURE addition forces a structured view of the data objects that you assign to a field symbol.
    FIELD-SYMBOLS <FS> STRUCTURE <s> DEFAULT <f>.
    The structure <s> is either a structured local data object in the program, or a flat structure from the ABAP Dictionary. <f> is a data object that must be assigned to the field symbol as a starting field. However, this assignment can be changed later using the ASSIGN statement.
    When you assign a data object to the field symbol, the system only checks that it is at least as long as the structure. You can address the individual components of the field symbol. It has the same technical attributes as the structure <s>.
    If <s> contains components with type I or F, you should remember the possible effects of alignment. When you assign a data object to a field symbol with a structure, the data object must have the same alignment, otherwise a runtime error may result. In such cases, you are advised to assign such data objects only to structured field symbols, which retain the same structure as the field symbol at least over the length of the structure.
    The STRUCTURE is obsolete; you should no longer use it. Field symbols defined using the STRUCTURE addition are a mixture of typed field symbols and a utility for casting to either local or ABAP Dictionary data types. If you want to define the type of a field symbol, include the TYPE addition in a FIELD-SYMBOLS statement. If you want to use casting, include the CASTING addition in an ASSIGN statement.
    Example using the obsolete STRUCTURE addition:
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             col1(2),
             col2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> STRUCTURE line1 DEFAULT wa,
                   <f2> STRUCTURE line2 DEFAULT wa.
    WRITE: / <f1>-col1, <f1>-col2, <f1>-col3,
           / <f2>-col1, <f2>-col2.
    Example using the correct syntax (TYPE and CASTING):
    DATA: wa(10) VALUE '0123456789'.
    DATA: BEGIN OF line1,
             col1(3),
             col2(2),
             col3(5),
          END OF line1.
    DATA: BEGIN OF line2,
             COL1(2),
             COL2 LIKE sy-datum,
          END OF line2.
    FIELD-SYMBOLS: <f1> LIKE line1.
    ASSIGN wa TO <f1> CASTING.
    FIELD-SYMBOLS: <f2> LIKE line2.
    ASSIGN wa TO <f2> CASTING.
    WRITE: / <f1>-col1, <F1>-col2, <F1>-col3,
           / <f2>-col1, <F2>-col2.
    In both cases, the list appears as follows:
    012 34 56789
    01 2345/67/89
    This example declares two field symbols to which different structures are attached. The string WA is then assigned to each of them. The output shows that the field symbols assign the strings component by component according to the type of the components.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
    THANKS
    MRUTYUN

  • Assigning a value to a field-symbol (workarea of type any)

    Dear forumers,
    I'm having a bit of difficulty in assigning a value to a field-symbol (it should be treated as a workarea of type any), but I'm given a syntax error instead:-
    The data object "<LFS_WORKAREA>" has no structure and therefore no component called "LFMON".
    What could have gone wrong and how may I resolve this (I must have missed something out)? I will still need <LFS_WORKAREA> to be defined as TYPE ANY.
    Please help. I'd appreciate any inputs at all. Thanks.
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
    " Create local field symbols
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
    " Create local variables
      DATA: lv_index TYPE sy-tabix.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    " Format posting periods
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        lv_index = sy-tabix.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        MOVE lv_lfmon TO <lfs_workarea>-lfmon.   " the syntax error occurs here  :(
        MODIFY pi_mbew FROM <lfs_workarea>
          INDEX lv_index
          TRANSPORTING lfmon.
        CLEAR: <lfs_workarea>,
               <lfs_lfmon>
               lv_lfmon,
               lv_index.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

    Most of us aren't in it for the points in any case...
    For your solution you've redundant code:
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    *  DATA: lo_workarea TYPE REF TO data.   "<--Not needed, because the LOOP AT ASSIGNING below does the work
    *  CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
    *  ASSIGN lo_workarea->* TO <lfs_workarea>.
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD
    Here's a couple of more efficient solutions, using LOOP AT INTO.
    FORM format_post_period  CHANGING    pi_mbew TYPE INDEX TABLE. " <-- Table type a little more specific
                                                                   "<--now you can use index operations
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper,
            lv_index TYPE sytabix.
      DATA: lo_workarea TYPE REF TO data.
      CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
      ASSIGN lo_workarea->* TO <lfs_workarea>.
    ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
      LOOP AT pi_mbew INTO <lfs_workarea>.
        lv_index = sy-tabix.    
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        MODIFY pi_mbew FROM <lfs_workarea>
           INDEX lv_index. " <--INDEX TABLE, so this is permitted.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

  • Passing unassigned field symbols to a method

    Hello Gurus,
    I work with a field symbol in a method and after the work is finished i have to use it i my program that i call the method from.
    The problem is that the field symbol gets assigned only in the method so i can`t get the field symbol as a changing parameter in my method because it is not assigned yet.
    I thought that i can return the field symbol from the method after it has been assigned, but i don`t know how. The <fs> is a dynamic itab that i created within the method.
    Can anyone help please ??

    Although already answered this code snippet might make it clearer
    my_line is your data structure  typically  an itab structure.
    For example
    TYPES:  BEGIN OF s_elements,
       tabname  type DD02L-tabname,
       tabclass type dd02l-tabclass,
       as4user  type dd02L-as4user,
       as4date  type dd02l-as4date,
       as4time  type DD02l-as4time,
       viewed(1) type c.
    TYPES: END OF    s_elements.
    Data: my_line            TYPE s_elements.
    1) get the structure of your itab automatically so you can build an FCAT simply for any structure without the horrendous usual coding to manipulate and create FCATS.
    CALL METHOD me->return_structure
           EXPORTING
                my_line = my_line.
    You need to make a table ZOGT data available in the class definition either as an attribute if you are using the class builder SE24 or as DATA in the relevant class section.
    data:
        zog         LIKE LINE OF lr_rtti_struc->components .
    data:
      zogt                    LIKE TABLE OF zog .
    method RETURN_STRUCTURE.
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( my_line ).
        zogt[]  = lr_rtti_struc->components.
    endmethod.
    Your structure details are now in table zogt.
    Use this to build an FCAT.
    CALL METHOD me->create_dynamic_fcat
          IMPORTING
                it_fldcat = it_fldcat.
    method CREATE_DYNAMIC_FCAT.
    LOOP AT zogt INTO zog.
          CLEAR wa_it_fldcat.
          wa_it_fldcat-fieldname = zog-name .
          wa_it_fldcat-datatype = zog-type_kind.
          wa_it_fldcat-inttype = zog-type_kind.
          wa_it_fldcat-intlen = zog-length.
          wa_it_fldcat-decimals = zog-decimals.
          wa_it_fldcat-coltext = zog-name.
          wa_it_fldcat-lowercase = 'X'.
          APPEND wa_it_fldcat TO it_fldcat .
        ENDLOOP.
    endmethod.
    Now having got your FCAT you can build your dynamic table.
        CALL METHOD me->create_dynamic_table
          EXPORTING
                it_fldcat = it_fldcat
          IMPORTING
                dy_table        = dy_table.
    (dy_table is defined as ref to data)
    method CREATE_DYNAMIC_TABLE.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING
                it_fieldcatalog = it_fldcat
           IMPORTING
                ep_table = dy_table.
    endmethod.
    Now populate your dynamic table as per sample code here
    field_symbols:
    <dyn_table>    TYPE  STANDARD TABLE.
    <dyn_wa>.
    data: dy_line            TYPE REF TO data.
    FORM populate_dynamic_itab.
      ASSIGN dy_table->* TO <dyn_table>.
       CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
      SELECT *
            FROM DD02L
            INTO  CORRESPONDING FIELDS OF TABLE <dyn_table>
            WHERE TABNAME LIKE  'ZHR%'.
    ENDFORM.
    Now you can display your grid and process your data.
    CALL METHOD z_object->display_grid
           EXPORTING
             g_outtab = <dyn_table>
             g_fldcat = it_fldcat
             i_gridtitle = i_gridtitle
             i_edit  = i_edit
             i_zebra = i_zebra
           CHANGING
             it_fldcat = it_fldcat
             gt_outtab = <dyn_table>.
    In the Method
    method DISPLAY_GRID.
    GET REFERENCE OF g_outtab INTO g_outtab1.
        GET REFERENCE OF g_fldcat INTO g_fldcat1.
        struct_grid_lset-edit = i_edit.  "To enable editing
        struct_grid_LSET-zebra = i_zebra.
        struct_grid_lset-grid_title = i_gridtitle.
        struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
        struct_grid_lset-stylefname = 'CELLTAB'.
         CALL METHOD grid1->set_ready_for_input
            EXPORTING
                 i_ready_for_input = '1'.
        CALL METHOD grid1->set_table_for_first_display
           EXPORTING
                 is_layout       = struct_grid_lset
            CHANGING
                 it_outtab       = gt_outtab
                 it_fieldcatalog = it_fldcat.
      ENDMETHOD.
    You can even easily code your own  column names if you so wish in the application program.
    Before calling the method that displays the grid encode the following macro.
    DEFINE col_name.
      read table it_fldcat into  wa_it_fldcat index &1.
      wa_it_fldcat-coltext = &2.
      wa_it_fldcat-outputlen = &3.
      modify it_fldcat from wa_it_fldcat index &1.
    END-OF-DEFINITION.
    Then have a subroutine in your application code something like this
    Form name_columns.
    Here before displaying you can change the field catalog to
    adjust your own column names.
    *col_name  col-nr 'your name' output length.
        col_name 1 'Table name' 30.
        col_name 2 'Table class' 12.
        col_name 3  'Changed By' 12.
        col_name 4  '    On'   12.
        col_name 5  '    At'   8.
        col_name 6  'Act' 3.
      i_gridtitle = 'HR ESS / ITS  ZHR Tables - Double click to display'.
      i_zebra = 'X'.
      i_edit = ' '.
    endform.
    Hope this clears it up a bit.
    Once you get this stuff working you can re-use 99% of the code for almost any structure making the whole process of OO ALV grid applications really simple.
    Yoy only need as well a standard dynpro with a custom container on it (se51).
    Cheers
    jimbo

  • Looping over fields from internal table

    In a FM I have to check records of two ITABs against each other. Most fields can be checked 1:1 but some must be checked according to some business logic.
    I first want to check field-by-field and then I want to deal with exceptions.
    Question: How can I loop over fields in an ITAB in such a manner that I can compare fields?

    Hi, you can loop thru the columns(fields) of an internal table like so.
    field-symbols: <fs>.
    loop at itab.
    do.
    * Here you can use the field name instead of SY-INDEX
       assign component sy-index of structure itab to <fs>.
       if sy-subrc <>.
       exit.
       endif.
    * Now that you have access to the field via field symbol, you can compare
    * this value.
    Write:/ <fs>.
    enddo. 
    endloop.
    Regards,
    Rich Heilman

Maybe you are looking for

  • OC4J http port in release 2

    i am deploying an oc4j application on release 2. but am not sure what is the oc4j http port from where i can access the web-site of the application deployed. also, what all configurations need to be done to make this work. in release 1, the server.xm

  • How to transfer iPhoto pics?

    I just can't seem to transfer my Iphoto pics and videos from my macbook pro to my new 5C Iphone? I know Itunes is somehow involved, but i can't make it work. Help?????   :-)

  • New computer/want to delete all ipod songs

    I got a new computer, and I just downloaded itunes. I want to delete all songs on my ipod and start over. How do I do this? Thank you.

  • 7.1 & my iPod *spontaneously combusts*

    I've had a good couple of days of complete and utter BS with the new iTunes update and am still left with a major problem! Initially, instead of syncing my iPod with three new albums and podcasts it decided to deleted everything on the iPod, as if my

  • The ipod universal dock just doesnt like cases.

    Its no doubt that all the dock adapters were meant to only fit the ipods with no case or anything. I have an ipod touch with a sort of rubber back caseing. The thing wont fit into any dock adapters, but fits into the dock without an adapter just fine