Populate dynamic table fields from internal table

Hi,
Im trying to populate an dynamic table , but it's giving me a few errors witch i can't solve ...
Basically i have an internal table with te following types :
DATA: BEGIN OF tab_docs41 OCCURS 0,
      conta TYPE bsis-hkont,
      banco TYPE t012t-text1,
      ano_3 TYPE i,
      ano_2 TYPE i,
      ano_1 TYPE i,
      jan TYPE  i,
      fev TYPE  i,
      mar TYPE  i,
      abr TYPE  i,
      mai TYPE  i,
      jun TYPE  i,
      jul TYPE  i,
      ago TYPE  i,
      set TYPE  i,
      out TYPE  i,
      nov TYPE  i,
      dez TYPE  i,
      total TYPE i,
      montante TYPE betrag11,
END OF tab_docs41.
and the following fieldcatalog , for the dynamic table :
DATA : ls_fieldcat TYPE lvc_s_fcat.
  DATA: lv_period TYPE i.
  DATA str_period TYPE string.
  SUBTRACT 3 FROM ano.
  MOVE ano TO str_period.
  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'CONTA'.
  ls_fieldcat-seltext = 'Conta do Razão'.
  ls_fieldcat-datatype = 'HKONT'.
*  ls_fieldcat-intlen = '10'.
  APPEND ls_fieldcat TO p_fieldcat.
Since the internal table, tab_docs41 it's allready filled how can i pass the tab_docs41 values to the corresponding fields of the dynamic table (the move-corresponding it's not working..)
  ASSIGN fs_data->* TO <fs_1>.
  CREATE DATA new_line LIKE LINE OF <fs_1>.
*  ASSIGN new_line->*  TO <fs_2>.
*** Next step is to create a work area for our dynamic internal table.
  LOOP AT tab_docs41.
   ASSIGN COMPONENT 'CONTA' OF STRUCTURE  tab_docs41 TO <fs2>.
But this last step it's not working ...
Can anyone help me please ?
Point's will be rewarded
Best Regards
Thanks in advance
João Martins

Looks like you have used the method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE to create the dynamic internal table.
You have to change the last part of the code:
FIELD-SYMBOLS:
<itab> TYPE STANDARD TABLE,
<wa> TYPE ANY,
<val> TYPE ANY .
ASSIGN fs_data->* TO <itab>.
CREATE DATA new_line LIKE LINE OF <itab>.
ASSIGN new_line->*  TO <wa>.
LOOP AT tab_docs41.
  ASSIGN COMPONENT 'CONTA' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-conta.
  ASSIGN COMPONENT 'BANCO' OF STRUCTURE <wa> TO <val>.
  <val> = tab_docs41-banco.
  APPEND <wa> to <itab>.
ENDLOOP.
BR,
Suhas

Similar Messages

  • Read contents of changing fields from internal table

    Hi Folks,
    Please help me in my query below:
    Consider there is a Z-table with two fields TABNAM and FIELD having values KNA1 and NAME1 respectively.
    In my report I have fetched entries for customers from KNA1. Now based on the field from Z-table I want to populate a variable suppose V_FREE_VAR with the value from KNA1 table.
    Here V_FREE_VAR is of CHAR200 so that it accomodate all types of values from KNA1.
    The value of Z-table FIELD can change daily i.e next day the value may be PSTLZ.
    So how can I read the particular field from internal table as the field to be read is dynamic.
    Note: using case is not feasible.
    Thanks in advance.
    Regards,
    Shardul

    @Hartmut P
    As Rob said i want to get the value of the field from internal table. the code is something like this.
    I_KNA1 contains records for customers.
    Suppose values of Z-table are in internal table I_TEMP_TABLE.
    Entries in I_TEMP_TABLE are as follows
    TABNAME      FIELDNAME
    KNA1                 NAME1
    The value of FIELNAME in Z-table can be changed
    Loop at I_TEMP_TABLE into WA_TEMP_TABLE.
    Read I_KNA1 into WA_KNA1 with key KUNNR = '0001002234'.
    IF SY-SUBRC EQ 0.
       CASE WA_TEMP_TABLE-FIELDNAME.
            WHEN 'NAME1'.
                 V_VAR = WA_KNA1-NAME1.
             WHEN 'PSTLZ'
                  V_VAR = WA_KNA1-PSTLZ.
    ENDIF.
    But using case is not appropriate as KNA1 contains 176 fields.

  • Table control from internal table giving problem.

    HI ALL,
    I am creating a table control using wizard from internal table in the program when i give work area it gives this error "The table work area G_TABC_WA does not exist or is not a structure"
    I have declared internal table and work like this.
    TYPES: BEGIN OF T_TABC,
             OPTID LIKE ZHRPMT_TRNSAC-OPTID,
             STGID LIKE ZHRPMT_TRNSAC-STGID,
             TETID LIKE ZHRPMT_TRNSAC-TETID,
             REQSR LIKE ZHRPMT_TRNSAC-REQSR,
             MUNIT LIKE ZHRPMT_TRNSAC-MUNIT,
           END OF T_TABC.
    DATA:     G_TABC_ITAB   TYPE T_TABC OCCURS 0,
                   G_TABC_WA     TYPE T_TABC. "work area
    why it is giving this error and how to correct this.
    thanks.

    Hay
    Hello there is very small mistake
    TYPES: BEGIN OF t_tabc,
    optid TYPE zhrpmt_trnsac-optid,
    stgid TYPE zhrpmt_trnsac-stgid,
    tetid TYPE zhrpmt_trnsac-tetid,
    reqsr TYPE zhrpmt_trnsac-reqsr,
    munit TYPE zhrpmt_trnsac-munit,
    END OF t_tabc.
    DATA: g_tabc_itab TYPE TABLE OF t_tabc ,
    g_tabc_wa LIKE t_tabc. "work area
    **Please reward suitable points***
    With Regards
    Navin Khedikar

  • How to find internal table fields from which table.

    Hello Experts,
    I have to use a dynamic select inner join query.
    SELECT (lv_string)
      FROM (from_tab)
      INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
      WHERE (where_tab).
    ELSEIF table_1 NE ''.
      SELECT *
      FROM (table_1)
      INTO CORRESPONDING FIELDS OF TABLE <fs_itab1>
      WHERE (where_tab).
    in that LV_string is dynamicaly select. from a structure which is a combination of say  VBAK and VBAP
    i have to
    CONCATENATE 'VBAK~' wa_fields-fname INTO str_temp.
    CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space
    CONCATENATE 'VBAP~' wa_fields-fname INTO str_temp.
      CONCATENATE lv_string str_temp INTO lv_string SEPARATED BY space.
    with there identifire....how to find that...
    Regards,
    Ketan.

    Ketan,
    I believe you CAN find this only when you are creating lv_string from your structure (or whatever it is).
    So paste that code that what is your 'structure' type and on what conditions you want to Fill lv_string from it.
    in that LV_string is dynamicaly select. from a structure which is a combination of say VBAK and VBAP
    If you have a custom or standard Structure from which you need to fill lv_string, then you should have no worries to full VBAK~ or VBAP~ because fieldnames will be always unique in any Structure and hence ~ additions are not necessarily needed.
    The issue can be in the case where you are picking few fields each from std tables VBAK and VBAP in your lv_string and
    your "(from_tab)" is an inner join condition. I believe in that case you should be able to identify VBAK~ and VBAP~ while populating lv_string itself. Also you can use DB view MASSVBAP.
    Regards,
    Diwakar

  • 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

  • How to read table fields form a table  having length of 7 characters

    HI all,
    could you please tell me how to read table fields from a table having length 7 characters, i have requirement that in my ztable i have 30 fields out of which 20 fields are location fields, i want to select 20 fields which have 7 characters length.
    please could any body suggest me on this issue.
    thanks,
    sre.

    hi,
    try like this
    create a data variable of type i as
    data: len type i.
    create internal table for 20 fields as
    data:begin of itab,
               fld 1 type .......
            end of itab.
    data:itab type itab1 occurs 0 with header line.
    loop at itab2. // original internal table which all fields.
    read table itab2 with index sy-tabix.
    len = strlen (itab2-fld).
    if len eq 7.
          move itab2 itab1.
          append itab1.
    endif.
    endloop.
    if helpful reward some points.
    with regards,
    Suresh.A

  • How to pass data from dynamic internal table to standard internal table

    hi experts,
    below is the piece of code which i have used in my requirement but the data is not moved.
    LOOP AT <tab> ASSIGNING <tab1>.
      MOVE-CORRESPONDING <tab1> TO wa.
      append wa TO  gt_outtab.
    ENDLOOP.
    here
    <tab> - dynamic internal table.
    <tab1>-dynamic internal table work area.
    gt_outtab - standard internal table.
    wa- standard internal table work area.
    i am not getting what additional thing i have to write.
    pls help me in this regard.
    thankx in advance.
    soham.p.

    Hello soham p ,
    I am also using the same logic but in my program it is working fine so you declare the fieldsymols like this and try and also check the dynamic internal contain the data or not.
    FIELD-SYMBOLS : <y_i_table>  TYPE STANDARD TABLE,
                                 <y_wa_table> TYPE ANY.
      LOOP AT <y_i_table> ASSIGNING <y_wa_table>.
        MOVE-CORRESPONDING <y_wa_table> TO y_wa_vfscaid.
        APPEND y_wa_vfscaid TO y_i_vfscaid.
        CLEAR y_wa_vfscaid.
      ENDLOOP.

  • How to do a SELECT from different tables into an internal table?

    How to do a SELECT from different tables into an internal table?
    I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
    REPORT  zinternal_table.
    TABLES:
      mara,
      marc,
      zperson.
    TYPES:
    BEGIN OF str_table1,
      v_name LIKE zperson-zname,
      v_matnr LIKE marc-matnr,
      v_emarc LIKE marc-emarc,
      v_werks_d LIKE marc-werks_d,
      v_dstat LIKE marc-dstat,
      END OF str_table,
      i_table1 TYPE STANDARD TABLE OF str_table1.
    DATA:
    BEGIN OF str_table2,
    v_mandt LIKE mara-mandt,
    v_ernam LIKE mara-ernam,
      v_laeda LIKE mara-laeda,
    END OF str_table2,
    itab_final LIKE STANDARD TABLE OF str_table2.

    first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
    u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
    then for all the entries in that internal table retrieve data from zperson into another internal table.
    then loop at one internal table
    read another internal table where key equals in both the tables.
    finally assign fileds if sy-subrc = 0.
    gs_finaltable-matnr = gs_table-matnr
    etc...
    and finally append gs_finaltable to gt_finaltable.
    there u go ur final table has all the data u want.
    regards
    Edited by: BrightSide on Apr 2, 2009 3:49 PM

  • How to handle field symbols internal table values?

    HI all,
              I declared field string as below.The below code is working fine.
    Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
              wa_itab like line of ITAB.
    field-symbol : <fs> type ITAB.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
    If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
    Data : BEGIN OF ITAB1 OCCURS 0,
             FIELD1 LIKE YAPOPLN-FIELD1,
             FIELD2 LIKE YAPOPLN-FIELD2,
             END OF ITAB1.
    field-symbol : <fs> LIKE ITAB1 OR  <FS> TYPE ANY.
    DATA :WA_ITAB1 LIKE LINE OF ITAB1.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
    .'FS' is not an internal table or defined in TABLES.
    Can anyone help me in this regard?
    Thanks,
    Balaji

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • How to move field symbol internal table to internal table with header line?

    Dear all,
    hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
    as i know field symbol internal table is without header line..
    so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
    Please advise...
    Thanks
    Regard,
    ToToRo.
    Edited by: @ToToRo@ on Aug 20, 2009 6:16 AM

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • Downloading data from internal table to xls file leading zeros are not disp

    Hai abap gurus,
    when i am downloading data from internal table to excle file. some field values in a column are with leading zeros and some others dont have leading zeros.but in the output it is showing without leading zeros. then how to get with exact values.
    Ex:
    <b>ECC Code.</b>
    045234
      88567
    098456 
    but output is giving like this:
    45234
    88567
    98456
    how to get the actual values.....
    plz help me in this matter.

    Dear Kiran,
    Those field in the internal table having Leading Zeroes, make those fields' datatype as character.
    Then use the function module to download the content of the internal table to the excel file.
    Regards,
    Abir
    Don't forget to Reward Points  *

  • How to print the data  if we take different fields from diffrent tables

    Hi ABAPers,
    I take diff fields from 3 tables. Those are
    these fields from EKBE
           EBELN
           EBELP
           BELNR
           BUZEI
           BWART
           BUDAT
           AREWR
           REEWR
           WERKS
           MWSKZ
    these fields from EKKO
           BUKRS
           BSART
           WAERS
    these field from EKPO
           TXZ01
           MATNR
           MTART
    I want to print the data all fields.What logic can i write?
    Please help me for this question and i am waiting for your response.
    Regards,
    Raja Sekhar.

    Hi,
    First you have to fetch data from all the three tables and then consolidate into final table.
    In Declaration:
    1.Declare Internal Table for EKKO holding:
    EBELN
    BUKRS
    BSART
    WAERS
    2.Declare Internal Table for EKPO holding:
    EBELN
    EBELP
    TXZ01
    MATNR
    MTART
    3.Declare Internal Table for EKBe holding:
    EBELN
    EBELP
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    *==> This table has
    MANDT
    EBELN
    EBELP
    ZEKKN
    VGABE
    GJAHR
    BELNR
    BUZEI
    as Primary keys field,you should have values for all the PK aotherwise you will get multiple entries*
    4.Declare a Final Internal Table i_final with all the fields you want
    EBELN
    EBELP
    BUKRS
    BSART
    WAERS
    TXZ01
    MATNR
    MTART
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    Data Fetching
    select EBELN
    BUKRS
    BSART
    WAERS
    from EKKO
    into table i_ekko
    where .........<selection criteria>.
    if not i_ekko is initial.
    select EBELN
    EBELP
    TXZ01
    MATNR
    MTART
    from EKPO
    into table i_ekpo
    for all entries in i_ekko
    where EBELN = I_EKKO-EBELN
    AND ......<If any other selection criteria>.
    if not i_ekpo is initial.
    select EBELN
    EBELP
    BELNR
    BUZEI
    BWART
    BUDAT
    AREWR
    REEWR
    WERKS
    MWSKZ
    from EKBE
    into table i_ekbe
    for all entries in i_ekpo
    where ebeln = i_ekpo-ebeln
    and ebelp = i_ekpo-ebelp
    and ..........<If any othet selection criteria>
    endif.
    endif.
    Consolidate
    sort i_ekko by ebeln.
    sort i_ekpo by ebeln ebelp.
    sort i_ekbe by ebeln ebelp.
    LOOP AT i_ekbe into wa_ekbe.
    read table i_ekko into wa_ekko with key ebeln = wa_ekbe-vbeln binary search.
    if sy-subrc = 0.
    ====>Move all the required firlds from I_EKKO to i_final  , like
    wa_final-BUKRS = wa_ekko-BUKRS.
    endif.
    read table i_ekpo into wa_ekpo with key ebeln = wa_ekbe-vbeln
    ebelp = wa_ekbe-ebelp binary search.
    if sy-subrc = 0.
    ====>Move all the required firlds from I_EKPO to i_final  , like
    wa_final-EBELP = wa_ekko-EBELP.
    wa_final-TXZ01 = wa_ekko-TXZ01.
    endif.
    ==>Also all the required fields from EKBE to final table, like
    wa_final-BELNR = wa_ekbe-BELNR.
    endloop.

  • Update ztable from internal table

    I want to update the Ztable from internal table datas.
    what is the syntax to update.
    Its urgent send with coding example is better

    Hi
    PARAMETERS: p_carrid TYPE sflight-carrid,
                percent(1) TYPE p DECIMALS 0.
    DATA sflight_tab TYPE TABLE OF sflight.
    FIELD-SYMBOLS <sflight> TYPE sflight.
    SELECT *
           FROM sflight
           INTO TABLE sflight_tab
           WHERE carrid = p_carrid AND
                 fldate = sy-datum.
    IF sy-subrc = 0.
      LOOP AT sflight_tab ASSIGNING <sflight>.
        <sflight>-price =
          <sflight>-price * ( 1 - percent / 100 ).
      ENDLOOP.
    ENDIF.
    <b>UPDATE sflight FROM TABLE sflight_tab.</b>
    Thanks
    Vijay
    PLZ reward points if helpful

  • Update databse from internal table statement not using index

    Hi Guys,
    We are updating a databse table from a file. The file has a couple of fields which have data different from what the database has (non-primary fields :). We upload the file data into an internal table and then update the database table from internal table. At a time, internal table is supposed to have 10,000 records. I did SQL trace and found that the update statement is not making use of the databse index.
    Should not the update statement here be using the table index (for primary key)?
    Regards,
    Munish

    ... as often there are recommendations in this forum which makes me wonder, how people overestimate their knowledge!!!
    Updates and Deletes do of course use indexes, as can be seen in the SQL Trace (use explain).
    Inserts don't use indexes, because in many databases inserts are just done somewhere, But also with the INSERT, the primary key is the constraint for the uniqueness condition, duplicate keys are not allowed.
    Coming to the original question, what is you actually coding for the update?
    What is the table, which fields are in the internal table and what are the indexes?
    Siegfried

  • How to transfer from internal table to table control ?

    How to transfer data from internal table to table control wihtout using select statement?

    HI
    GOOD
    The commands in the flow logic are:
    LOOP AT itab [INTO wa] WITH CONTROL ctrl.
    ENDLOOP.
    This statement assigns an internal table itab of the ABAP program to the table control and triggers a parallel loop run over the table control rows displayed on the screen and over the internal table itab. The additions INTO and WITH CONTROL are possible at the time of PBO, but not at PAI. The assignment of the loop to the table control takes place at PAI through the internal table.
    Using the INTO addition, the fields of the internal table itab are written to the work area wa at the time of PBO and the content of wa is transported, line by line, to the identically-named fields of the table control on the screen. Without the INTO addition, you must use an internal table with a header line. Then the content of the header line is transported line by line to the identically-named fields of the table control on the screen at the time of PBO. No module is required for filling the table control rows.
    Conversely, at the time of PAI, the internal table rows are not automatically filled with the contents of the table control rows. Instead, you must call a dialog module within the loop that modifies the table.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fa/0970a4543b11d1898e0000e8322d00/content.htm
    THANKS
    MRUTYUN^

Maybe you are looking for

  • Why does my website only not work in Google Chrome?

    I've made a pretty simple webpage just to test out the drag and drop function. This website works completely when I open it in Firefox, Internet Explorer, using an iPad and another tablet. However when I open it in chrome, it only displays the preloa

  • Firefox required Authentication when enter in reporting services, only in firefox and safari

    Hi SSRS required authentication when enter in Firefox an safari, work fine in IE, GOOGLE AND OPERA this link not work, firefox required credentials: https://support.mozilla.org/en-US/kb/Firefox%20asks%20for%20user%20name%20and%20password%20on%20inter

  • Name reporting on credit report

    Hi guys I have a predicament and I would like some advice on the issue.As many Mexicans I have a really long name, and like such some problems are expected when reporting it. Everything started last year when I tried to apply for a Capital One secure

  • Waveform chart time sometimes decreases

    I have a waveform chart with three plots vs time with update mode set to strip chart.  It is demonstrating strange behavior which I have never noticed before.  The time sample numbers at the extents of the axis sometimes decrease and the plots shift

  • How to troubleshoot ORA-04031 error?

    I'm getting ORA-04031 errors such as the this one: ORA-04031: unable to allocate 264 bytes of shared memory ("shared pool","unknown object","PCUR^a9c5b70f","kglob") Here is the server's information: OS: RHEL MEMORY: 48 GB There is another database on