How to Copy data from field symbol to Dynamic Internal Table

Hi,
I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
REPORT  ztest.
DATA:
       gd_dref          TYPE REF TO data,
       gd_dref1          TYPE REF TO data.
FIELD-SYMBOLS:  <fs1>   TYPE any,
                           <fs_wa> TYPE any,
                            <field>    TYPE any,                  
                            <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
*Copy data from p_src to p_dest*
PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                         p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
*DATA : lt_csks LIKE p_dest WITH HEADER LINE.
START-OF-SELECTION.
  CREATE DATA gd_dref TYPE (p_src).
  CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
   ASSIGN gd_dref->* TO <fs_wa>.
   ASSIGN gd_dref1->* TO <fs_wa1>.
   SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
*Write out data from FIELD SYMBOLS TO Table.
   loop at <fs_wa1> into <fs_wa>.
     do.
       assign component  sy-index
          of structure <fs_wa> to <field>.
       if sy-subrc <> 0.
       exit.
       endif.
       if sy-index = 1.
         write:/ <field>.
       else.
       write: / <field>.
       endif.
     enddo.
   endloop.
*Need Logic To Copy the Data to p_dest table from <fs_wa1>.
*p_dest is a table having a similar structure to table p_src .
*Need Logic To Copy the Data to p_dest table from <fs_wa1>.
EXIT.
Thanks in Advance.

try this...
I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
Cheers...
report  ztest.
data:
  gd_dref type ref to data,
  gd_dref1 type ref to data,
  gd_dref_str type ref to data,
  gd_dref_tab type ref to data.
field-symbols:
  <fs1> type any,
  <fs_wa> type any,
  <fs1_dest_str> type any,
  <fs_dest_tab> type any table,
  <field> type any,
  <fs_wa1> type any table.
* contains data from p_src
*Copy data from p_src to p_dest*
parameters: p_src like dd02l-tabname default 'vbak',
* name of dynamic internal table *
            p_dest like dd02l-tabname default 'vbap'.
* name of dynamic internal table*
*data : lt_csks like p_dest with header line.
start-of-selection.
  create data gd_dref type (p_src).
  create data gd_dref1 type table of (p_src).
  assign gd_dref->* to <fs_wa>.
  assign gd_dref1->* to <fs_wa1>.
  select * from (p_src) into corresponding fields of table <fs_wa1>
  up to 3 rows
  where vbeln ne space.
  create data gd_dref_str type (p_dest).
  create data gd_dref_tab type standard table of (p_dest).
  assign gd_dref_str->* to <fs1_dest_str>.
  assign gd_dref_tab->* to <fs_dest_tab>.
*write out data from field symbols to table.
  loop at <fs_wa1> into <fs_wa>.
    " break-point here - can see vbeln/waers/create date/ etc move over to new structure
    " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
    " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
    break-point.
    move-corresponding <fs_wa> to <fs1_dest_str>.
    insert <fs1_dest_str> into table <fs_dest_tab>.
**    do.
**      assign component  sy-index
**         of structure <fs_wa> to <field>.
**      if sy-subrc <> 0.
**        exit.
**      endif.
**      if sy-index = 1.
**        write:/ <field>.
**      else.
**        write: / <field>.
**      endif.
**    enddo.
  endloop.
  " write out some dest data from the dest table build from previous loop
  loop at <fs_dest_tab> assigning <fs1_dest_str>.
    do.
      assign component sy-index of structure <fs_wa> to <field>.
      if sy-subrc <> 0.
        exit.
      endif.
      if sy-index = 1.
        write:/ <field>.
      else.
        write: / <field>.
      endif.
    enddo.
  endloop.

Similar Messages

  • Data from field symbol into an internal table or workarea

    Hi Experts,
    I have field symbol in which i get the data. I want to get this data into an internal table of type any or into an work area. How is this possible.
    My declaration for field symbol is as follow:
    FIELD-SYMBOLS: <l_t_data> TYPE any.
    DATA l_r_data TYPE REF TO data.
        CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
        ASSIGN l_r_data->* TO <l_t_data>.
    I get the data in this field symbol <l_t_data>. by passing into a funtion module. and I get the data into it. Now i have to assign the values of this field symbol to any internal table or to a work are how do i do it. Please help.
    Regards,
    Prashant.

    Not exactly sure what you need here, but.....
    FIELD-SYMBOLS: <l_t_data> TYPE TABLE.   "<<-- Change this
    FIELD-SYMBOLS: <l_s_data> TYPE ANY.      "<<---Add This
    DATA l_r_data TYPE REF TO data.
    CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
    ASSIGN l_r_data->* TO <l_t_data>.
    Loop at <l_t_data> assigning <l_s_data>.
    * Do what ever using <l_s_data>
    Endloop.
    Regards,
    Rich Heilman
    Edited by: Rich Heilman on Feb 28, 2008 2:42 PM

  • How to extract data from info cube into an internal table using ABAP code

    HI
    Can Anyone plz suggest me
    How to extract data from info cube into an internal table using ABAP code like BAPI's or function modules.
    Thankx in advance
    regds
    AJAY

    HI Dinesh,
    Thankq for ur reply
    but i ahve already tried to use the function module.
    When I try to Use the function module RSDRI_INFOPOV_READ
    I get an information message "ERROR GENERATION TEST FRAME".
    can U plz tell me what could be the problem
    Bye
    AJAY

  • Are field symbols and Dynamic internal tables consistant?

    Hi,
    Are field symbols and Dynamic internal tables
    always consistent?
    In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
    this happens once in 3 to 4 runs
    any solution...
    I have proper clear and refresh statements in program.
    Thanks,
    Hardik

    Anurag,
    Thanks for a quick reply. Here I am sending a small piece of my code.
    MOVE-CORRESPONDING OUTTAB TO DYNTAB.
          CLEAR IT_UDATE.
          CLEAR : T_KBETR .
          READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
          CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
          ASSIGN (T_KBETR) TO <FS> .
          SUBRC5 = SY-SUBRC .
          IF SUBRC5 = 0 .
              <FS> =  OUTTAB-KBETR .
          ENDIF .
    read statement will always return CO_POS .
    while debuging this code a few times
    <b>ASSIGN (T_KBETR) TO <FS> .</b>
    returns sy-subrc = 4
    and that was leading the program to short dump earlier.
    now, as I have a check DYNTAB-KBETR holds no value on display.
    this happens very few times. (most of the times report is displaying desired output)
    Thanks,
    Hardik

  • How to read data from field symbol containing Table

    I defined a field symbols for reading output of a BRF plus rule however since fielk symbol is of type any
    I cannot read its contents
    Any inputs are highly appreciated
    Please see attachment explaining problem

    Thanks a lot for your help
    However It did not work for me as it started giving error incompatible types
    Here is my code
    constants:lv_function_id type if_fdt_types=>id value '3440B5B078B21EE3BC9EB53C42F84A45'.
    data:lv_timestamp type timestamp,
          lt_name_value type abap_parmbind_tab,
          ls_name_value type abap_parmbind,
          lr_data type ref to data,
          lv_counter type i value 0,
          lr_target type ref to data,
          lx_fdt type ref to cx_fdt,
          lo_trace type ref to if_fdt_trace,
          lo_lean_trace type ref to if_fdt_lean_trace,
          la_z_string type if_fdt_types=>element_text,
          lv_role_name  type grac_role_name,
          lv_result type string.
    field-symbols <la_any> type any.
    field-symbols <role_name> type grac_s_od_role_detail.
    field-symbols <system> type string.
       types:
        begin of ys_access ,
                  role_name type  string,
                  system_name   type string,
                end of ys_access .
      types:
        yt_access type table of ys_access .
    field-symbols: <access_item> type table,
                    <ls_req_access> type ys_access.
    data con_name type if_fdt_types=>element_text.
    data ls_any type ys_access.
    * All method calls within one processing cycle calling the same function must use the same timestamp.
    * For subsequent calls of the same function, we recommend to use the same timestamp for all calls.
    * This is to improve the system performance.
    * If you are using structures or tables without DDIC binding, you have to declare the respective types
    * by yourself. Insert the according data type at the respective source code line.
    * GET TIME STAMP FIELD lv_timestamp.
    * Process a function and record trace data, passing context data objects via a name/value table.
    * Prepare function processing:
    ls_name_value-name = 'Z_STRING'.
    la_z_string = 'P1'.
    get reference of la_z_string into lr_data.
    ls_name_value-value = lr_data.
    insert ls_name_value into table lt_name_value.
    * Create the data to store the result value after processing the function
    * You can skip the following call, if you already have
    * a variable for the result. Please replace also the parameter
    * EA_RESULT in the method call CL_FDT_FUNCTION_PROCESS=>PROCESS
    * with the desired variable.
      cl_fdt_function_process=>get_data_object_reference( exporting iv_function_id      = lv_function_id
                                                                    iv_data_object      = '_V_RESULT'
                                                                    iv_timestamp        = lv_timestamp
                                                                    iv_trace_generation = abap_true
                                                          importing er_data             = lr_data ).
      assign lr_data->* to <la_any>.
      try.
          cl_fdt_function_process=>process( exporting iv_function_id = lv_function_id
                                                      iv_timestamp   = lv_timestamp
                                                      iv_trace_mode  = if_fdt_constants=>gc_trace_mode_lean
                                                     "iv_trace_mode  = if_fdt_constants=>gc_trace_mode_lean_required
                                            importing ea_result      = <la_any>
                                                      eo_trace       = lo_trace
                                            changing  ct_name_value  = lt_name_value ).
          lo_lean_trace ?= lo_trace.
          lo_lean_trace->save( ).
          catch cx_fdt into lx_fdt.
    * You can check CX_FDT->MT_MESSAGE for error handling.
      endtry.
    * Get context values after processing:
      cl_fdt_function_process=>get_context_value( exporting  iv_function_id = lv_function_id
                                                             iv_trace_generation = abap_true
                                                             iv_timestamp   = lv_timestamp:
                                                             iv_data_object = '3440B5B078B21EE3BC9EFF599C110ADD' "Z_STRING
                                                   importing ev_data             = lv_result ). " Suggested variable: la_z_string
      create data lr_target type grac_s_od_role_detail.
    *  assign <la_any> to <role_name>.
      assign lr_target->* to <la_any>.
       loop at lt_name_value into ls_name_value.
        if ls_name_value-name cs 'RESULT'.
          assign ls_name_value-value  to <la_any>.
            ls_any = ls_name_value-value  .
        endif.
        endloop.
        access_item = <la_any>.
    * assign ( )<la_any> to <access_item>.
    * assign component 1 of structure <la_any> to <rolename>.
    *   assign <la_any> to <ls_req_access>.
    * lr_target = <la_any>.
    * assign lr_target->* to <role_name>.
    * lv_role_name = <role_name>.
      lv_result = lv_result.

  • How to fetch data from bseg based  on 2 internal tables in 1 select query?

    hi,
    i have bukrs and belnr in one internal table and bukrs and vbeln in another internal table..now if i select from bseg twice using for all entries for fields bukrs vbeln and bukrs belnr twice in 2 select statements its fine..but since bseg is a huge table i want to use select only once..but the problem is that none of the belnrs in the one internal table will have vbeln in another internal table....ie if vbeln is selected from bseg based on belnr in 1 internal table non eof those vbeln will be equal to vbeln on another internal tables..in this scenario even if i take all data from two internal tables into 1 single internal table and then use for all entries on vbeln and belnr of that table ..but i think this will not work because and AND operator will not work because no record will satisfy both vbeln and belnr conditions..even if i use OR operator if the 1st condition satisfies the select clause will not enter into the second clause and all the records will not be fetched...Please help how should i tackle this..

    Hi vijaya,
    no simple select statement solution so far.
    As BSEG is a huge table you should try to get the full key values into another internal table first.
    SAP avoids direct selections from BSEG.
    Pleas consider the use of one of the secondary index tables first:
          BSAD : Accounting: Secondary Index for Customers (Cleared Items)
          BSAK : Accounting: Secondary Index for Vendors (Cleared Items)
          BSAS : Accounting: Secondary Index for G/L Accounts (Cleared Item
          BSEC : One-Time Account Data Document Segment
          BSEG : Accounting Document Segment
          BSID : Accounting: Secondary Index for Customers
          BSIK : Accounting: Secondary Index for Vendors
          BSIS : Accounting: Secondary Index for G/L Accounts
    you may include
          BKPF : Accounting Document Header
    for restrictions about time and document type.
    The last step is a FOR ALL ENTRIES selection from BSEG providing the full key values.
    Although you may have even more selects, the overall performance will be much better.
    Regards,
    Clemens

  • How to copy data from mac to external hard

    how to copy data from mac to external hard

    ok - since you'll be sharing it with a PC - connect it to your windows pc - then format from there - instead of NTFS format - choose exFAT.
    or, you can read the link below on how to do it in dos mode.
    http://answers.microsoft.com/en-us/windows/forum/windows_7-files/how-can-i-forma t-external-drive-in-exfat-not-in/0f6bf19a-19d6-4470-ae05-53ddf26bb476?msgId=1860 eae3-3488-4eea-8326-f87b89d9851b
    once you've formatted it - you can now use it in both your macbook and windows computer.

  • How to copy data from transparent table to our own ceated z table?

    How to copy data from transparent table to our own ceated z table?
    Plz tell me different methods and which one is best?
    Is get data from sflight into table z* is correct?

    Hi Ajay,
    let us consider you have to copy EKKO table to ZEKKO table
    1. In ABAP program define internal table based on EKKO
    <b>     eg: i_ekko</b>
    2. Select the data from EKKO to i_ekko
    <b>     eg: select * from ekko into table i_ekko.</b>
    3. insert into Z-TABLE from the internal table
    <b>     eg: INSERT EKKO FROM TABLE I_EKKO.
               COMMIT WORK.</b>
    <u>To insert in internal table you can use the following:</u>
    1. INSERT [wa INTO|INITIAL LINE INTO] itab [INDEX idx].
    2. INSERT [wa INTO|INITIAL LINE INTO] TABLE itab.
    3. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO itab2 [INDEX idx3].
    4. INSERT LINES OF itab1 [FROM idx1] [TO idx2] INTO TABLE itab2.
    <u>To inert in database table, use the following:</u>
    1. INSERT INTO <dbtabname> [CLIENT SPECIFIED] VALUES wa.
    2. INSERT <dbtabname> [CLIENT SPECIFIED] FROM TABLE itab.
    3. INSERT <dbtab> [CLIENT SPECIFIED]. oder
    4. INSERT <dbtabname> [CLIENT SPECIFIED] ... .
    <b>Reward points.. if helpful.
    Cheers !
    Moqeeth.</b>

  • How to read data from a CLUSTER STRUCTURE not cluster table.

    Hi,
    how to read data from a CLUSTER STRUCTURE not cluster table.
    regards,
    Usha.

    Hello,
    A structre doesnt contain data.. so u cannot read from it. U need to find out table of that structure and read data from it.
    Regards,
    Mansi.

  • How to retrieve data from domain(Value Range)  of the table

    hi
    how to retrieve data from domain(Value Range)  of the table
    thanks

    Hello,
    You can try using the FM: DOMAIN_VALUE_GET TB_DOMAINVALUES_GET.
    BR,
    Suhas
    Edited by: Suhas Saha on Mar 24, 2009 10:08 AM

  • How to add one more field to an exist internal table

    hi abapers
    i am a very new abap programmer and just started learning it.
    i want to know How to add one more field to an exist internal table.
    lemme me put my question in a very simple way.
    i have a internal table having fields f1,f2,f3 and which also that internal also contains some data.
    now i want to add two more fields (mm & nn) to that internal table now.
    how can i do that.
    and i wanna know the websites names where i can find some brain teasing questions in abap programming.
    eagerly waiting for ur reply
    regards,
    Maqsood A Khan

    Hi, MAQSOOD.
    You can insert more fields in your internal table like this.
    refer this code snippet.
    DATA : BEGIN OF tbl_itab OCCURS 0.
            INCLUDE STRUCTURE zsdtc009.
    DATA :  vkorg   LIKE vbak-vkorg,  "inserted one
            vtweg   LIKE vbak-vtweg,  "inserted one
            vkbur   LIKE vbak-vkbur,  "inserted one
            vkgrp   LIKE vbak-vkgrp,  "inserted one
           END OF tbl_itab.
    you can also read the book "Teach yourself abap in 21 days"
    at http://cma.zdnet.com/book/abap/
    but that book is just about basic concept of abap and report program.
    it doesn't give a lecture for on-line program.
    you can get pdf version books(about abap, sap...things) from sap.
    http://help.sap.com/printdocu/core/Print46c/en/Data/htm/english.htm
    I wish I could help you.
    Regards
    Kyung Woo.

  • Join data from a file with an internal table

    Hi to everybody!!
    I need help, I don't know how to join two differents data, one of them is internal...
    This select fill my itab
        SELECT PERNR PERID VORNA NACHN  FROM PA0002 APPENDING TABLE itab_tabla
            WHERE
            PA0002~BEGDA <= SY-DATUM AND
            PA0002~ENDDA >= SY-DATUM AND
            PERID  = G_PERID.
         ENDLOOP.
    Now I have to insert inside the table more data that pass from a file...but I don't know how to join this... can anybody help me?
    Thanks a lot
    Regards,
    Rebeca

    HI,
    you will need to upload the file by Using the FM GUI_UPLOAD.
    this will take the data from the file to an internal table that you will have to declare.
    once you get the data in to your table,you can merge both the tables in to another final table or in the 1st internal table if all the fields are there and modify the table.so the table will have the records of both the tables.
    after you get the data in your second table"
    loop at itab2.
    move: <field 1> to itab1.
              <field 2> to itab1.
    modify itab1.
    endloop.

  • How to get the NameTab Structure(X031L) for Dynamic internal table?

    when we pass standard table to the FM 'DD_GET_NAMETAB' we will get the
    nametab structure(x031l), like this i want to get the same structure for
    dynamic internal  table . how can I achieve this
    please help me...

    Hi,
    try this method
    REPORT zmaschl_create_data_dynamic .
    TYPE-POOLS: slis.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
          is_fcat LIKE LINE OF it_fcat.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data.
    DATA: new_line  TYPE REF TO data.
    FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
                   <l_line>  TYPE ANY,
                   <l_field> TYPE ANY.
    Build fieldcat
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'       EXPORTING           i_structure_name = 'SYST'       CHANGING           ct_fieldcat      = it_fcat[].   LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.        MOVE-CORRESPONDING is_fcat TO is_fieldcat.        is_fieldcat-fieldname = is_fcat-fieldname.        is_fieldcat-ref_field = is_fcat-fieldname.        is_fieldcat-ref_table = is_fcat-ref_tabname.        APPEND is_fieldcat TO it_fieldcat.   ENDLOOP.
    Create a new Table
    CALL METHOD cl_alv_table_create=>create_dynamic_table       EXPORTING        it_fieldcatalog = it_fieldcat       IMPORTING        ep_table        = new_table.
    Create a new Line with the same structure of the table.
    ASSIGN new_table->* TO <l_table>.CREATE DATA new_line LIKE LINE OF <l_table>.ASSIGN new_line->* TO <l_line>.
    Test it...
       DO 30 TIMES.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          <l_field> = sy-index.
          INSERT <l_line> INTO TABLE <l_table>.
       ENDDO.
       LOOP AT <l_table> ASSIGNING <l_line>.
          ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
          WRITE <l_field>.
       ENDLOOP.

  • ALV display using dynamic field catalog and dynamic internal table

    hi ,
    please guide me for ALV display using dynamic field catalog and dynamic internal table.
    Thank you.

    Hi Rahul,
    maybe thread dynamic program for alv is helpful for you. More information about the [SAP List Viewer (ALV)|http://help.sap.com/saphelp_nw70/helpdata/EN/5e/88d440e14f8431e10000000a1550b0/frameset.htm]. Also have a look into the example programs SALV_DEMO_TABLE*.
    Regards Rudi

  • How to copy data from one column to other column

    hi,
    can any one tell me how to copy data of  one column to other column for some specific data
    example
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120                   
    p002       2007                   90               100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    i want to copy data of p001 and p002 from prevplansales to current plansales
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120              120     
    p002       2007                   90               100              100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    is it possible to do?
    please suggest me.
    i will assign points

    Hi,
    I think the needed techniques are already described in the documentation, e.g. in
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    or
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    The main techiques used in the above example to bind the filter of the planning function to selected (marked) objects in the analysis item or to drop down boxes (or both). These techniques are used in the above examples.
    Regards,
    Gregor

Maybe you are looking for

  • Adobe Flash Player 11.3 r300 has stopped working

    I have Firefox 13.0.1, Win 7 Home Edition 64 bit, latest adobe flash player version 11.3.300.262. Latest nvidia drivers 301.42 - WHQL, 260 gtx nvidia card. I did a clean reinstall for nvidia drivers, and flash drivers, still same problem. Everytime I

  • Curious key binding issue with Openbox

    I'm learning about setting up key bindings for actions in Openbox. One of things that I wanted to do is to have the root-menu and client-list-combined-menu set to keyboard shortcuts. This part I borrowed from a post in the forums and it does exactly

  • Combining result of three queries to form a single table

    Hi .. I have three select queries. Each of them returns a single column. I want the result of these queries into a single table.. I tried this way.. select * from (first select),(second select),(third select); this gives duplicate rows... Any held wo

  • Enquiry about adding new field in SAP transaction vl10c

    Hi, requirement: I want to add additonal field after executing  SAP transaction vl10c. help me pooja

  • Changes in Unicode

    Hi, Does anyone have a list the FMs and the statements that we need to change in Unicode system? regards,