Dynamic internal  tables using field symbols

Hello,
Is it possible to create a dynamic table where the no of fields in the internal table can be created dynamically(using field symbols).
Say sometimes internal tables with 10 fields and depending upon the requirement the fields can be dynamically increased or decreased in runtime.
Thanks.

Hi,
Go through the following code....
*Data definitions
*** Tables
data: lt_data type ref to data.
data: lt_fieldcatalog type lvc_t_fcat.
*** Structure
data: ls_fieldcatalog type lvc_s_fcat.
*** Data References
data: new_line type ref to data,
      fs_data type ref to data.
*** Field Symbols
field-symbols: <fs_data> type ref to data,
               <fs_1> type any table,
               <fs_2>,
               <fs_3>.
*Populating the internal table with fieldnames required for our dynamic
*internal table
ls_fieldcatalog-fieldname = 'MANDT'.
append ls_fieldcatalog to lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CARRID'. "Fieldname
ls_fieldcatalog-inttype = 'C'. "Internal Type C-> Character
append ls_fieldcatalog to lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CONNID'.
ls_fieldcatalog-inttype = 'N'.
append ls_fieldcatalog to lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'FLDATE'.
ls_fieldcatalog-inttype = 'D'.
append ls_fieldcatalog to lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'PRICE'.
ls_fieldcatalog-inttype = 'P'.
append ls_fieldcatalog to lt_fieldcatalog.
ls_fieldcatalog-fieldname = 'CURRENCY'.
ls_fieldcatalog-inttype = 'C'.
append ls_fieldcatalog to lt_fieldcatalog.
*Calling the method CREATE_DYNAMIC_TABLE
call method cl_alv_table_create=>create_dynamic_table
     exporting
       it_fieldcatalog = lt_fieldcatalog
     importing
       ep_table = fs_data
     exceptions
       generate_subpool_dir_full = 1
       others = 2
if sy-subrc <> 0.
endif.
*Assigning Field-Symbol to our dynamic internal table
assign lt_data to <fs_data>.
*Internal Table is ready, now to put data in that table
*** So <FS_1> now points to our dynamic internal table.
assign fs_data->* to <fs_1>.
*** Next step is to create a work area for our dynamic internal table.
create data new_line like line of <fs_1>.
*** A field-symbol to access that work area
assign new_line->*  to <fs_2>.
*** And to put the data in the internal table
select
      mandt
      carrid
      connid
      fldate
      price
      currency
              from sflight
              into corresponding fields of table <fs_1>.
*** Access contents of internal table
loop at <fs_1> assigning <fs_2>.
do 5 times.
assign component sy-index of structure <fs_2> to <fs_3>.
write:  <fs_3>.
enddo.
skip 1.
endloop.
top-of-page.
write:/5 'FUJITSU CONSULTING COMPANY' inverse color 6,
       50 sy-datum inverse color 6,
       70 sy-pagno inverse color 6.
uline.
<REMOVED BY MODERATOR>
Vijay C
Code Formatted by: Alvaro Tejada Galindo on Apr 14, 2008 1:47 PM

Similar Messages

  • Delete row from internal table using field symbol.

    Hi friends,
      I created dynamic internal table using field symbol. I want to delete some data using where clause.
    for example. i want to use like,
        DELETE <FS> WHERE KUNNR = WA_KNA1-KUNNR.
    Like the above statment it won't work. How i can use delete with where clause in field symbols.
    Hope any one can help me.
    Thanks and regards
    Srikanth. S

    hi Srikanth,
    I think you have to LOOP through the whole internal table and check each line and decide to delete or not:
    LOOP at <itab> INTO <wa>.
    ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <wa> TO <field>.
    CHECK <field> IS ASSIGNED.
    IF <field> EQ WA_KNA1-KUNNR.
    DELETE ...
    ENDIF.
    UNASSIGN <field>.
    ENDLOOP.
    hope this helps
    ec

  • Creating dynamic internal table(Not field symbol table)

    Hi Experts,
    I am facing problem creating Intarnal table
    I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
    I have written----
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
         it_fieldcatalog           = it_fldcat
          it_fieldcatalog           = me->gt_fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = lt_new_table
       e_style_fname             =
        EXCEPTIONS
         generate_subpool_dir_full = 1
         OTHERS                    = 2.
        ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
        CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
        ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
    above logic creating dynamic field symbol table.... But I want create normal internal table.
    Thanks,
    Rajasekhar

    Hi
    What do you mean?
    It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
    Max

  • Dynamic Internal table with field symbol

    I made the report where the user enters two different tables and two fields that are to be compared.
    Eg. If I enter (MARA & NAME1) and (MARC & NAME2) , I wish to compare all the entries of Mara-name1 against all entries in Marc-name2.
    <u>The code I need to write is:</u>
    DATA:
      gdo_data      TYPE REF TO data.
    DATA:
      gdo_data1      TYPE REF TO data.
    FIELD-SYMBOLS:
      <gt_itab>     TYPE table,
        <wa> LIKE <gt_itab>,                        "<gt_itab>,
      <gs_entry>    TYPE ANY.
    FIELD-SYMBOLS:
      <gt_itab1>     TYPE table,
        <wa1> LIKE <gt_itab>,                        "<gt_itab>,
      <gs_entry1>    TYPE ANY.
    PARAMETERS:
      p_table    TYPE tabname,            "    DEFAULT 'KNA1',
      p_fld      TYPE fieldname.          "  DEFAULT 'KUNNR'.
    PARAMETERS:
      p_table1    TYPE tabname,            "    DEFAULT 'KNA1',
      p_fld1      TYPE fieldname.
    DATA: var TYPE fieldname.
    var = p_fld.
    DATA: var1 TYPE fieldname.
    var1 = p_fld1.
    START-OF-SELECTION.
      CREATE DATA gdo_data TYPE TABLE OF (p_table).
      ASSIGN gdo_data->* TO <gt_itab>.
      CREATE DATA gdo_data1 TYPE TABLE OF (p_table1).
      ASSIGN gdo_data1->* TO <gt_itab1>.
      SELECT * FROM (p_table) INTO CORRESPONDING FIELDS OF TABLE <gt_itab>.
      SELECT * FROM (p_table1) INTO CORRESPONDING FIELDS OF TABLE <gt_itab1>.
    <b>  LOOP AT <gt_itab> ASSIGNING <gs_entry>.
        READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
             WITH KEY (var1) = <gt_itab>-(var).
        IF sy-subrc EQ 0.
          MESSAGE 'Success' TYPE 'S'.
        ENDIF.
      ENDLOOP.</b>
    END-OF-SELECTION.
    But the portion in bold is creating error: <b><gt_itab> is a table without a header lineand therefore has no component called "".</b>
    please help.

    Hi Amit
    Try like this
    LOOP AT <gt_itab> ASSIGNING <gs_entry>.
    READ TABLE <gt_itab1> ASSIGNING <gs_entry1>
    WITH KEY (var1) = <b><gs_entry></b>-(var).
    IF sy-subrc EQ 0.
    MESSAGE 'Success' TYPE 'S'.
    ENDIF.
    ENDLOOP.
    Regards,
    Atish

  • Some help needed on dynamic internal tables and field symbols

    Hi,
    I have a dyn internal table <dyn_table_r>.
    One of its fields is kna1-kunnr.
    I have another wa <fs>, with only one field alt_kunnr.
    now i want to modify  the data of <dyn_table_r>-kna1-kunnr from <fs>-alt_kunnr
    How should i do it?
    Regards ,
    Harshit Rungta

    Harshit Rungta:
    You have opened a number of related questions today. I'd like to see the other ones closed before you continue with this one.
    I'll lock this but will re-open it once the others are marked as solved.
    Rob

  • Subtotals in dynamic internal table using alv grid

    hi experts i have created one dynamic table.  The requirement is to display the subtotals in the output using reuse_alv_grid.
    Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT
    the above is the thread related and could any one please provide the sample code for this task.
    can any one post the solution for that.
    rewards points will be awarded.
    khazi

    * ASSINING STRUCTURE FOR FILD CATLOGS
    DATA: DYN_TABLE    TYPE REF TO DATA,
          DYN_LINE     TYPE REF TO DATA,
          LS_FIELDCAT TYPE LVC_S_FCAT,
          LT_FIELDCAT TYPE LVC_T_FCAT.
      LOOP AT LT_DMTAB INTO LS_DMTAB.
        CLEAR LS_FIELDCAT.
        LS_FIELDCAT-FIELDNAME = LS_DMTAB-SDATE .
        LS_FIELDCAT-DATATYPE  = 'DEC'.
        LS_FIELDCAT-INTTYPE   = 'P'.
        LS_FIELDCAT-INTLEN    = '16' .
        LS_FIELDCAT-DECIMALS  = '03'.
        LS_FIELDCAT-JUST      = 'C'.
        APPEND LS_FIELDCAT TO LT_FIELDCAT.
      ENDLOOP.
    *& For grouping the table rows for Under Line
      LS_FIELDCAT-FIELDNAME = 'ULFIELD' .
      LS_FIELDCAT-DATATYPE  = 'INT'.
      LS_FIELDCAT-INTTYPE   = 'P'.
      LS_FIELDCAT-INTLEN    = '2' .
      LS_FIELDCAT-DECIMALS  = ''.
      APPEND LS_FIELDCAT TO LT_FIELDCAT.
      "* Create dynamic internal table and assign to Field-Symbol
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_FIELDCAT
        IMPORTING
          EP_TABLE        = DYN_TABLE.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN DYN_TABLE->* TO <LT_AREA_F>.
      "* Create dynamic work area and assign to Field Symbol
      CREATE DATA DYN_LINE LIKE LINE OF <LT_AREA_F>.
      ASSIGN DYN_LINE->* TO <LS_AREA_F>.
    You check in Field cat level you will get  Check Sub total field will exist
    Thanks and regards
    Jogu

  • Reference comp in dynamic internal table using CL_ALV_TABLE_CREATE

    Hi,
    I am using CL_ALV_TABLE_CREATE to create a dynamic internal table. Everything works fine, but there is one problem with it. How can i create a component in the internal table that is actually a REF TO a certain data type. i.e. later i would like to store a reference to some dataobj in this component of the internal table.
    I cannot use cl_abap_*descr classes to create internal table because of some other reasons, otherwise it would have been easy to do it.
    Any kind of help would be highly appreciated.
    Thanks and best regards,
    Ghufran

    Hi Ghufran,
    I do have an idea about the class <b>CL_ALV_TABLE_CREATE</b> , but i have writen an exmaple code to create a Dynamic Iternal table, please have a look, it may help you
    *& Report  Z_DYNAMIC_INTERNALTABLE                                 *
    report  z_dynamic_internaltable             .
    data: d_ref type ref to data,
    d_ref2 type ref to data ,
    i_alv_cat type table of lvc_s_fcat,
    ls_alv_cat like line of i_alv_cat.
    types tabname like dcobjdef-name .
    parameter: p_tablen type tabname.
    data: begin of itab occurs 0.
    include structure dntab.
    data: end of itab.
    field-symbols : <f_fs> type table,
    <f_fs1> type table,
    <f_fs2> type any,
    <f_fs3> type table,
    <f_fs4> type any.
    refresh itab.
    call function 'NAMETAB_GET'
    exporting
    langu = sy-langu
    tabname = p_tablen
    tables
    nametab = itab
    exceptions
    no_texts_found = 1.
    loop at itab .
    ls_alv_cat-fieldname = itab-fieldname.
    ls_alv_cat-ref_table = p_tablen.
    ls_alv_cat-ref_field = itab-fieldname.
    append ls_alv_cat to i_alv_cat.
    endloop.
    internal table build
    call method cl_alv_table_create=>create_dynamic_table
    exporting it_fieldcatalog = i_alv_cat
    importing ep_table = d_ref .
    assign d_ref->* to <f_fs>.
    select * from (p_tablen) into corresponding fields of table <f_fs>.
    loop at <f_fs> assigning <f_fs2>.
    assign itab-fieldname to <f_fs4>.
    loop at itab.
    write: / <f_fs4>.
    endloop.
    endloop.
    Thanks
    Sudheer

  • Internal table to field symbol

    hi all,
    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.
    *data : dyn_itab2 type ANY table.
    selection-screen begin of block b1 with frame.
    parameters: p_table(30) type c.
    selection-screen end of block b1.
    start-of-selection.
    BREAK-POINT.
    perform get_structure.
    perform create_dynamic_itab.
    perform get_data.
    PERFORM OUTPUT.
    *perform write_out.
    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.
    *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.
    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.
    here i want  to assighn the structure of dy_table to internal atble.
    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.
    Select Data from table.
    select * into table <dyN_table> UP TO 10 ROWS
    from (p_table).
    endform.
    Write out data from table.
    FORM OUTPUT.
    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.
    how can i achieve this one.
    regards
    siva

    Hi,
    Check this Code ...
    LOOP AT <dyn_table> INTO <dyn_wa>.
        DO.
          ASSIGN COMPONENT sy-index
          OF STRUCTURE <dyn_wa> TO <fs_field> .
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
          IF sy-index = 1.
            WRITE:/ <fs_field>.
          ELSE.
            WRITE: <fs_field>.
          ENDIF.
        ENDDO.
      ENDLOOP.
    For reference check below code
    DATA: it_fieldcat        TYPE lvc_t_fcat                         . " Field catalog
    DATA: wa_fieldcat  LIKE LINE OF it_fieldcat. " Field catalog
    DATA: it_dyn_table      TYPE REF TO data,     " Dynamic table
          it_wa_dyn_table   TYPE REF TO data.     " Dynamic table
    *       Field sysmbols           Begin with <fs>                      *
    FIELD-SYMBOLS:  <fs_dyn_table>       TYPE STANDARD TABLE, " Dynamic tbale
                    <fs_dyn_table_temp>  TYPE ANY           , " Dynamic tbale
                    <fs_field>           TYPE ANY           , " Temp field for data assignment
                    <fs_field_temp>      TYPE ANY           . " Temp field for data assignment
    *       Macro                                                         *
    * Macro Defination
    * Building field catalog using macro defination
    DEFINE m_fieldcat.
      wa_fieldcat-fieldname   = &1.
      wa_fieldcat-scrtext_l   = &2.
      wa_fieldcat-coltext     = &2.
      wa_fieldcat-no_zero     = &3.
      wa_fieldcat-hotspot     = &4.
      wa_fieldcat-outputlen   = &5.
      wa_fieldcat-emphasize   = &6.
    * Appending workarea to internal table
      append wa_fieldcat to it_fieldcat.
      clear wa_fieldcat.
    END-OF-DEFINITION.
    *&      Form  f005_prepare_field_catalog
    *       text
    form f005_prepare_field_catalog .
      REFRESH: it_fieldcat.
    * Build the field catalog
      m_fieldcat text-007 text-008 c_blank  c_blank c_30 c_blank.
      m_fieldcat text-009 text-010 c_blank  c_blank c_30 c_blank.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      w_date1 = so_date-low.
    * Loop to generate grid column at run time
    * Loop - Till the lower date not equal to higer date
      WHILE so_date-high GE w_date1.
    * Changing date into actual date format using edit mask
        WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
        m_fieldcat w_var4 w_var4 c_flag c_blank c_12 c_blank.
        w_date1 = w_date1 + c_count.
        CLEAR w_var4.
      ENDWHILE.
    *&      Form  f007_create_dynamic_table
    *       text: Create dynamic table
    form f007_create_dynamic_table .
    * Call method to create dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = it_fieldcat
        IMPORTING
          ep_table                  = it_dyn_table
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      SORT it_final_temp BY equnr point.
      SORT it_final BY equnr point psort idate.
      ASSIGN it_dyn_table->* TO <fs_dyn_table>.
      CREATE DATA it_wa_dyn_table LIKE LINE OF <fs_dyn_table>.
      ASSIGN it_wa_dyn_table->* TO <fs_dyn_table_temp>.
      IF it_final_temp IS NOT INITIAL.
        LOOP AT it_final_temp INTO wa_final_temp.
    * Assign equipment number and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-007 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign equipment number value to field symbol
          <fs_field> = wa_final_temp-equnr.
    * Assign Short Description and it's field data to field symbols (Dynamic table)
    * Assign field name to field symbol
          ASSIGN text-009 TO <fs_field_temp>.
    * Assign component name and it's value to dynamic table
          ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
    * Assign short description value to field symbol
          <fs_field> = wa_final_temp-psort.
    * Loop to assign value of run time generated column.
          IF it_final IS NOT INITIAL.
            LOOP AT it_final INTO wa_final WHERE equnr = wa_final_temp-equnr
                                            AND point = wa_final_temp-point.
              w_date1 = wa_final-idate.
              WRITE w_date1 TO w_var4 USING EDIT MASK '__-__-____'.
              ASSIGN w_var4 TO <fs_field_temp>.
              ASSIGN COMPONENT <fs_field_temp> OF STRUCTURE <fs_dyn_table_temp> TO <fs_field>.
              <fs_field> = wa_final-cdiff.
              CLEAR: wa_final, w_var4, w_date1.
            ENDLOOP.
          ENDIF.
          CLEAR: wa_final_temp.
    * Assign field symbol temporary table to final dynamic table
          APPEND <fs_dyn_table_temp> TO <fs_dyn_table>.
          CLEAR: <fs_dyn_table_temp>.
        ENDLOOP.
      ENDIF.
    endform.                    " f007_create_dynamic_table

  • Can I pass a table using field-symbols to a PERFORM

    Can I pass an internal table using a field-symbol via a PERFORM that is stored in another program.
    For example, I want to pass lt_data using a field-symbol.  If I can do this, please tell me how to define a field-symbol for a table and how I setup the parameters on the FORM.
       perform TEST_FIELD_SYMBOLS in program zadd_data
                      changing lt_data[]
                       if found.
    Thanks.
    Regards,
    Ryan

    Since in ABAP all FORM-paramters are passe call-by reference, it makes imho no difference if u pass a table directly or via a fieldsymbol.
    U can pass a REF TO DATA to a form and then assign it to an FS like shown in the following example.
    TYPES: BEGIN OF s_data,
             data TYPE c,
           END OF s_data,
           s_tab TYPE STANDARD TABLE OF s_data.
    TYPES: r_tab TYPE REF TO data.
    START-OF-SELECTION.
      DATA: t_foo TYPE s_tab.
      DATA: ref_foo TYPE r_tab.
      GET REFERENCE OF t_foo INTO ref_foo.
      PERFORM my_form_fs USING ref_foo.
    FORM my_form_fs USING u_ref TYPE r_tab.
      FIELD-SYMBOLS: <fs> TYPE s_tab.
      DATA: w_tab TYPE s_data.
      ASSIGN u_ref->* TO <fs>.
      w_tab-data = 'X'.
      APPEND w_tab TO <fs>.
    ENDFORM.
    This also works for external performs....
    Best regards,
        Sebastian
    Message was edited by:
            Sebastian Rötzel

  • Dynamic Internal table using another internal table values

    Hello All,
    I have an internal table ITAB1, which will get populated inside the program. This ITAB1 will have only one field.
    I want to create an internal table dynamically with the values of ITAB1( single field internal table ) as fields.
    Thanks in advance.
    Best Regards,
    Sasidhar Reddy Matli.

    at this wiki
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/individualcellcoloringindynamic+alv
    you can find an example where I build an internal table
    you can look at the coding where I loop though the internal table and at the value to the fieldname.
    * dynamic fields
    LOOP AT ta_pernrs INTO wa_pernrs.
    WRITE wa_pernrs-pernr TO h_ri_pernr.
    is_lvc_cat-fieldname = wa_pernrs-pernr.
    is_lvc_cat-ref_field = 'massn'.
    is_lvc_cat-ref_table = 'PERNR'.
    is_lvc_cat-just = 'C'.
    CONCATENATE it_0002-inits it_0002-nachn(1) INTO is_lvc_cat-scrtext_s SEPARATED BY space.
    CONCATENATE it_0002-inits it_0002-nachn INTO is_lvc_cat-scrtext_m SEPARATED BY space.
    CONCATENATE it_0002-inits it_0002-nachn INTO is_lvc_cat-scrtext_l SEPARATED BY space.
    APPEND is_lvc_cat TO it_lvc_cat.
    and then ofcourse the creation of the table which is also mentioned in the earlier reply
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = it_lvc_cat
    IMPORTING
    *ep_table = ta_output.*** Create a new Line with the same structure of the table.
    ASSIGN ta_output->* TO <ta_output>.*
    CREATE DATA new_line LIKE LINE OF <ta_output>.
    ASSIGN new_line->* TO <l_line>.
    kind regards
    arthur de smidt

  • How to assign a whole internal table to field symbol

    Can anyone explain me that , can we assign the whole internal table to a field symbol .If yes please explain with some simple example by assigning an internal tabl data to a field symbol and how to loop on to that field symbol to write the data from it.
    Please don't paste the F1 help .
    Thanks,
    Rose.

    hi
    good
    check this code
    ) Defining the table records and the field symbol in a similar type.
    just an ordinary standard table
    TYPES: BEGIN OF it_vbak_line,
    vbeln LIKE vbak-vbeln,
    vkorg LIKE vbak-vkorg,
    vtweg LIKE vbak-vtweg,
    spart LIKE vbak-spart,
    kunnr LIKE vbak-kunnr,
    END OF it_vbak_line.
    DATA: it_vbak TYPE TABLE OF it_vbak_line.
    FIELD-SYMBOLS: <it_vbak_line> TYPE it_vbak_line.
    or as a screaming fast hash table for keyed reads
    TYPES: BEGIN OF it_vbpa_line,
    vbeln LIKE vbak-vbeln,
    kunnr LIKE vbak-kunnr,
    END OF it_vbpa_line.
    DATA: it_vbpa TYPE HASHED TABLE OF it_vbpa_line
    WITH UNIQUE KEY vbeln.
    FIELD-SYMBOLS: <it_vbpa_line> TYPE it_vbpa_line.
    2) In ITAB processing, utilize the ASSIGNING command.
    loop example
    LOOP AT it_vbak ASSIGNING <it_vbak_line>.
    look at records--populate it_zpartner
    read example
    READ TABLE it_vbpa ASSIGNING <it_vbpa_line>
    WITH TABLE KEY vbeln = <it_vbak_line>-vbeln.
    3) Refer to the field symbol's fields in the loop or after the read.
    wa_zpartner-vkorg = <it_vbak_line>-vkorg.
    wa_zpartner-vtweg = <it_vbak_line>-vtweg.
    wa_zpartner-spart = <it_vbak_line>-spart.
    wa_zpartner-kunag = <it_vbak_line>-kunnr.
    wa_zpartner-kunwe = <it_vbpa_line>-kunnr.
    See the code example below for further detail. The code was written in R/3 4.6C and should work for all 4.x versions.
    thanks
    mrutyun^

  • How to build a internal table of field symbols.

    Hi,
    I want to build a internal table, which consists of several field symbols. Each field symbol points to an entry of  other internal tables. All of these tables have different structure definition. How can I implement it. If it is possible, it can save a lot of table query time.
    I will be very appreciate for your help.
    Best Regards, Jun

    hello jun
    i hope the following example give the some idea to build internal table fileds with differen field symbol data types.
    FIELD-SYMBOLS:<f1> type any,<f2> TYPE ANY.
    data:BEGIN OF itab,
         t1 type i value 10,
         t2(30) type c value 'john',
       t3 type p DECIMALS 3 value '4.7658',
       END OF itab.
      ASSIGN itab to <f1>.
      DO 3 TIMES.
      ASSIGN COMPONENT sy-index OF STRUCTURE <f1> TO <f2>.
      WRITE <f2>.
      ENDDO.
    types:begin of it_line,
          i1 type i,
          t1 type string,
          p1 type p DECIMALS 3,
      end of it_line.
      data:itab1 type table of  it_line.
    FIELD-SYMBOLS:<f1>.
      ASSIGN itab1 to <f1>.
    and also u can refer the following links
    1->  http://help.sap.com/saphelp_wp/helpdata/en/fc/eb387a358411d1829f0000e829fbfe/content.htm
    2--> http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3923358411d1829f0000e829fbfe/content.htm
    Thanks&Regards
    sreenivas p

  • Copying Dynamic Internal Table

    Hi All,
            I have created a Dynamic internal table using field symbols.  Now i need to copy that dynamic itab to another internal table, because I am not familiar with field symbols. Can anybody tell me how can i copy that dyn_itab to another itab.
    code which I used to create dyn_table:
    LS_FIELDCATALOG-FIELDNAME = 'CHINA_TOT'.
    LS_FIELDCATALOG-INTTYPE = 'I'.
    append LS_FIELDCATALOG to LT_FIELDCATALOG.
    assign LT_DATA to <FS_DATA>.
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = LT_FIELDCATALOG
         importing
           ep_table = <FS_DATA>
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    if sy-subrc <> 0.
    endif.
    So <FS_1> now points to our dynamic internal table.
    assign <FS_DATA>->* to <FS_1>.
    HERE <FS_1> is a dynamic itab.

    First you need to create another table with the structure that you have.
    call method cl_alv_table_create=>create_dynamic_table
         exporting
           it_fieldcatalog = LT_FIELDCATALOG
         importing
           ep_table = <FS_DATA2>
         exceptions
           generate_subpool_dir_full = 1
           others = 2
    field-symbols  : <fs_line1>, <fs_line2>, <fs_tmp1>, <fs_tmp2>.
    assign <FS_DATA2->* to <FS_2>.
    Now FS_1 and FS_2 are the tables.
    Also create work areas for the tables.
    CREATE DATA gw_line1 LIKE LINE OF <fs_1>
    CREATE DATA gw_line2 LIKE LINE OF <fs_2>.
    ASSIGN gw_line1->* TO <fs_line1>.
    assign gw_line2->* to <fs_line2>.
    With field symbols, you cannot move the rows directly, you will have to move it field by field.
    Once all the values are populated in the first table, copy it with the following logic.
    loop at <fs_1> into <fs_line1>
    Loop at   LT_FIELDCATALOG into LS_FIELDCATALOG.
    ASSIGN COMPONENT ls_fieldcatalog-fieldname OF STRUCTURE <fs_line1> TO <fs_tmp1>.
    ASSIGN COMPONENT ls_fieldcatalog-fieldname OF STRUCTURE <fs_line2> TO <fs_tmp2>.
    <fs_tmp2> = <fs_tmp1>
    endloop.
    append <fs_line2> to <fs_2>
    endloop.

  • How to populate one internal table from another using field symbols

    Hi Gurus,
      I have a problem. I have to populate one internal table (sructure t_otput) from another internal table (sructure t_from) using field symbol.
    Structure for from table.
    types: begin of t_from,
             year(4) type c,
             ww(2) type c,
             site type marc-werks,
             demand type i,
           end of t_from.
    Structure for output table.
    types: begin of t_display,
             title(30),
             WW1(10),
             WW2(10),
             WW3(10),
           end of t_display.
    The from table looks like this:
    Year | WW | Site | Demand
    2005 | 1  | OR1  | 12.00
    2005 | 2  | OR1  | 13.00
    2005 | 3  | OR1  | 14.00
    The display table which has to be populated should look like this:
    Title  | WW1   | WW2   | WW3
    OR1    |       |       |
    Demand | 12.00 | 13.00 | 14.00
    How to populate display table using field symbol?
    Please give code snippets
    Thanks,
    Gopal

    Gopal,
    Here is the code, however I am not vary clear about the ORG1 and Demand display that you have shown in the display. I am sure with this code it should not be a big deal to tweak in whatever manner you want.
    TABLES : marc.
    TYPES: BEGIN OF type_display,
    title(30),
    ww1(10),
    ww2(10),
    ww3(10),
    END OF type_display.
    TYPES: BEGIN OF type_from,
    year(4) TYPE c,
    ww(2) TYPE c,
    site TYPE marc-werks,
    demand TYPE i,
    END OF type_from.
    data : t_from type table of type_from,
           t_display type table of type_display.
    field-symbols : <fs_from> type type_from,
                    <fs_display> type type_display.
    data : wa_from type type_From,
           wa_display type type_display.
    wa_from-year = '2005'.
    wa_from-ww   = '1'.
    wa_from-site = 'OR1'.
    wa_from-demand = '12.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '2'.
    wa_from-site = 'OR1'.
    wa_from-demand = '13.00'.
    insert wa_from  into table t_from.
    wa_from-year = '2005'.
    wa_from-ww   = '3'.
    wa_from-site = 'OR1'.
    wa_from-demand = '14.00'.
    insert wa_from  into table t_from.
    data : variable(3) type c.
    field-symbols : <fs_any> type any.
    break-point.
    Loop at t_from assigning <fs_from>.
    variable = 'WW'.
    wa_display-title = <fs_from>-site.
    concatenate variable <fs_from>-ww into variable.
    assign component variable of structure wa_display to <fs_any>.
    <fs_any> = <fs_from>-demand.
    endloop.
    append wa_display to t_display.
    clear wa_display.
    loop at t_display assigning <Fs_display>.
      write :/ <fs_display>.
    endloop.
    Note : Please award points if this helps you.
    Regards,
    Ravi

  • How To Read Field Values Form Dynamic Internal Table

    Hi,
    I Created a dynamic internal table using.
    FIELD-SYMBOLS: <gt_table> TYPE STANDARD TABLE,
                   <wa_gt_table>,
                   <l_fvalue> TYPE ANY.
    This Interanl table is working well, and all values are populated to an ALV.
    Now I try to set a link
    for that I am using below code
          READ TABLE <gt_table> ASSIGNING <l_fvalue> index rs_selfield-tabindex.
          IF sy-subrc EQ 0.
            insplot = <l_fvalue>-prueflos.
    Now it is showing a syntax error :
    the data object <l_fvalue> has no structure and there for no component called prueflos
    Regards
    Nausal

    Hi,
    Refere following code
    Local Field Symbol
      FIELD-SYMBOLS: <lf_any> TYPE ANY.                     "Changed data
      LOOP AT <gf_dyna_table> ASSIGNING <gf_dyna>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <gf_dyna> TO <lf_any>.
          IF sy-subrc NE 0.
            EXIT.
          ENDIF.
          IF ls_attach-line IS INITIAL.
            ls_attach-line = <lf_any>.
          ELSE.
            CONCATENATE ls_attach-line <lf_any> INTO ls_attach-line
                                                SEPARATED BY lc_tab.
          ENDIF.
        ENDDO.
        CONCATENATE lc_cret ls_attach-line  INTO ls_attach-line.
      Append Changed Data to attachement table
        APPEND ls_attach TO gt_attach.
      Clear
        CLEAR : ls_attach.
      ENDLOOP.
    Regards,
    Prashant

Maybe you are looking for

  • Data access error during workflow- import in FDM

    I am trying to perform import in FDM.But getting 'Data Access Error'. Any suggestions on this......

  • Organization of the dirty buffers in the write list

    Hello, 1.) Where places the server process the dirty buffers in the write list, at the beginning or at the end? Dirty buffers would like to become a flag in the write list? Can anybody explain me the organisation of the WRITE LIST of the database buf

  • How to delete or overwrite .csv file

    hi... i need some help here..can anyone teach me how to delete or overwrite an existing .csv file.?..in my .csv file there will be two columns which is column 1( 8 length) and 2 column ( 4 length). please...i need the answer asap..really appreacite y

  • Are there any 32 bit trials for After Effects CS5?

    I wanted to use After Effects and Premire for more solid video editing, but I have a 32 bit version of Windows 8.1. I found a page about CS5.5 Support for 32 but Windows but I'm not sure how to follow this tutorial before buying the software. I wante

  • Feature Request: Asset-sharing

    Adobe Illustrator recently posted a survey (Shared Content Survey) highlighting potential asset-sharing capabilities in future versions of Adobe CC applications. The lack of this seemingly logical feature has been a constant frustration for me and ma