Populate Final internal table from Dynamic internal table

Hello,
I have ti display data in ALV grid whose structure is fixed. I am dynamically selecting data iin an internal table.
Now from this dynamic internal table, i need to populate my final internal table whose structurte is fixed.
Please help.
Rgds,
Himanshu

Hello Himanshu,
When you say dynamic internal table there are two things one is the actual structure and other one is field table that holds information for all the fields used to create dynamic internal table.
No if you want to move data from dynamic table to fixed internal table then you can try as follows:
1.
field-symbols <field_name> TYPE C.
field-symbols <field_value> TYPE C.
Now you either use
LOOP AT fields_itab.
ASSIGN fields_itab-fieldname to <field_name>.
ASSIGN COMPONENT <field_name> OF STRUCTURE <structure_name> TO <field_value>
Now you move value from <field_value> to required field in fixed internal table.
i.e.
itab-fieldname = <field_value>.
Other way to do this:
If you fields order is constant then you can also use index in assign component statement.
do <no_of_fields> times.
    ASSIGN COMPONENT sy-index OF STRUCTURE <structure_name> TO <field_value>.
rest is same as first method.
Hope this help!
I have given sudo code and you need to work on it little.
Thanks,
Augustin.

Similar Messages

  • Deleting from Dynamic Internal table

    Hi,
    How can we delete data from dynamic internal table...
    I have a dynamic internal table <fs_dyn_table> which is of type any and can have any fields...
    I want to delete all those records which have a value of '10' in a field named field1
    I have written my delete statement in the following manner..
    DELETE <fs_dyn_table> WHERE field1 = '10'.....but it is not working...it gives me an error...stating that the line type of table must be statically defined.

    Hi,
    Loop on the internal table into a field-symbol of line type same as the internal table.
    Use assign component statement and then delete the corresponding record.
    Regards,
    Ankur Parab

  • Hi, Bapi or function module to update RBCO table from an internal table.

    I have a requirement to  update RBCO table from an internal table.  is there any Bapi or function module  or any other method other than update, modify statements.
    Moderator message: Welcome to SCN!
    Moderator message: please do more research before asking, show what you have done yourself when asking.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on Jul 12, 2011 12:28 PM

    I don't know if any FM exists for your requirement. But you may like to copy it into a custom table and modify it according to your enterprise needs.

  • Updating database table from an internal table

    Hi All,
    I am updating a database table from an internal table.
    I am changing the non-key fields in that table.
    when I check sy-subrc = 4.
    Record already exists, because I am changing non-key fields of the
    database table.
    Is there any addition like to accept the duplicate keys with update.
    Alternatively, I have used Modify, It is adding new record,
    Again, I have search the old record and use Delete on the database table.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

    Hi,
    You are right, the field which I am trying to change is a part of primary key.
    Because, sy-subrc = 4. says,
    No line with specified primary key exits in the database table.
    I have a Z-tabel, with Kunnr Vkorg Matnr Bzirk Bztxt Split_percentage
    In this table primary key consists of KunnrVkorgMatnr+Bzirk.
    I am able to change the Split_percentage using UPDATE.
    Now, my client want to change Bzirk, Bztxt also in the table.
    How can I Go.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP ABAP Consultant

  • How to create a table from an existing table with new column

    Hi !
    Please help me.
    I want to create a table from an existing table with data and add two new column to the new table.
    What will be the syntax?

    craete table new_table as select a.*, 'somevalue' new_col1, 'somevalue'
    new_col2 from old_table a;Also there is a pitfall - newly created table will accept column type and precision from the select statement, so further you can be needed to modify columns
    if you want to have VARCHAR2 instead of CHAR for example:
    SQL> create table new_dept as select dept.*, 'New data' new_col from dept;
    Table created.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            CHAR(8)
    SQL> alter table new_dept modify (new_col varchar2(8));
    Table altered.
    SQL> desc new_dept
    Name                                      Null?    Type
    DEPTNO                                             NUMBER(2)
    DNAME                                              VARCHAR2(14)
    LOC                                                VARCHAR2(13)
    NEW_COL                                            VARCHAR2(8)Rgds.
    Didn't see michael's post - it reflects the fix for this problem using CAST.
    Message was edited by:
    dnikiforov

  • Insert data into fact table from source database tables

    here i try to insert data into fact table from source database tables here is the query 
    ALTER procedure [dbo].[facttable]
    as
    insert into [pp dw].dbo.Dimfact(Prod_ID,Production_ID,Material_ID,Equip_ID,WC_ID,Recipe_ID,Quantity,costprice)
    select Products.[Product ID],[Production ID],Materials.[Material ID],[Equipment ID],[Work Centre ID],[Recipy ID],Quantity,[cost price]
    from
    [PRODUCTION PLANNING 2].dbo.[Products],
    [PRODUCTION PLANNING 2].dbo.[Production Detail],
    [PRODUCTION PLANNING 2].dbo.[Material category],
    [PRODUCTION PLANNING 2].dbo.[Materials],
    [PRODUCTION PLANNING 2].dbo.[Equipment],
    [PRODUCTION PLANNING 2].dbo.[Working Centre] ,
    [PRODUCTION PLANNING 2].dbo.[Recipies]
    where
    Products.[Product ID] in (13, 14, 15, 16, 17) and
    [Production Detail].[Production ID] in (1, 2, 3) and
    [Materials].[Material ID] in (1, 2, 3, 4, 5) and
    [Equipment].[Equipment ID] in (1, 2, 3, 4) and
    [Working Centre].[Work Centre ID] in (1, 2, 3) and
    [Recipies].[Recipy ID] in (1, 2, 3) and
    [Material category].[Category ID] in (8, 9, 10, 11, 12, 13)
    and when i execute query it shows me error 
    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dimfact_Dimproduct". The conflict occurred in database "pp dw", table "dbo.Dimproduct", column 'Prod_ID'.
    ERD IS
    HOW TO SOLVE THIS PROBLEM?

    I cant see any join conditions in your query posted. Whats the purpose of the query above. It will just bring you a cartesian product (cross join) of tables involved subjected to filters. Are you sure this is the correct query?
    The error you're getting may be because you've not yet populated DimProduct or may be because of logic you used in popultaing DimProduct causing it to miss some records which is what query is referring to in above case.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Create one tables from 2 different tables

    Hi,
    How I can create one table from 2 different tables. Source tables have data and I want to include it in new table.
    I try this:
    create table NEW_ONE
    select * from OLD_ONE
    union
    select * from OLD_ONE2;
    But it didn't work correctly :/

    I don't have any error. This syntax create table NEW_ONE, but this table have columns only from OLD_ONE table :/ There aren't any column from OLD_ONE2 :/ Any suggestions?
    I don't forget about "as" in my query, only in this post.
    Edited by: tutus on Sep 8, 2008 6:36 AM

  • Can we run an assignment on a qualified table from a main table?

    Can I run an assignment on a qualified table from a main table.
    For example: My main table Vendor and Qualified  Table is Company Qualified .
    Company Qualified - VendorNr (Non- Qualifier),Company(Qualifier,lookupFlat - Company)
    Company  - Name,Description (It has valid values in it already).
    How to add a default value into the Company Qualified table.
    When i add a assignment like
    If(is_null(Company Qualified [Record],default lookup value from Company)  ...it says invalid.
    Any help greatly appreciated  thanks

    This is not possible currently in MDM.  I've tried many times to find a good way to do this and so far have been unsuccessful.  I also have tried to have a workflow on the main table call an assignment in a lookup / qualified table, and that doesn't work either.  The biggest reason is because you have to select a table field when you create an assignment, and it doesn't give you the option to choose fields within a table.
    Hopefully they will address this in a future release.
    Edited by: Harrison Holland on Jun 3, 2008 2:33 PM

  • PLS-00327 when updating table from a remote table inside a PLSQL procedure

    Hi,
    Inside a PL/SQL procedure,I want to update a table from a remote table :
    begin
    UPDATE rachel1 set NEW_TEN_CODE =
    (SELECT NEW_TEN_CODE FROM rachel@REFI
    WHERE rachel1.OLD_TEN_CODE=rachel.OLD_TEN_CODE@REFI);
    end;
    I receive the error :
    PLS-00327: "RACHEL" is not in SQL scope here
    When I extract the update from the procedure and I run from SQL (without begin ... end), it works :
    SQL> UPDATE rachel1 set NEW_TEN_CODE =
    2 (SELECT NEW_TEN_CODE FROM rachel@REFI
    3 WHERE rachel1.OLD_TEN_CODE=rachel.OLD_TEN_CODE@REFI);
    So, why doesn't the update work inside the PL/SQL procedure ?
    What have I to do ?
    I need to run this command inside the procedure.
    Regards,
    Rachel

    Hi,
    Yes, the owner of the procedure have select on RACHEL@REFI.
    My oracle version is : 8.1.7.4.
    In fact, I've resolved the problem by doing :
    begin
    UPDATE rachel1 set NEW_TEN_CODE =
    (SELECT NEW_TEN_CODE FROM rachel@REFI
    WHERE rachel1.OLD_TEN_CODE=rachel.OLD_TEN_CODE);
    end;
    Regards,
    Rachel

  • Lgical table from two physical table

    Hi,
    I am trying to design a logical fact table from two physical table. One table has transaction data and another has accounting data. The requirement is, I need to merge the rows between these two tables, where were it matches. If the keys are not matching between these two table then also I need to bring those rows from both tables as separate rows. How can i do this? Also can i have a logical table as source for my fact table.

    You'll need outer joins in your physical layer and you can drag the columns from both physical tables to a single logical table and you will see in the BMM layer it will create the two logical table sources.

  • Populate data from dynamic internal table

    Hi
    I have dynamic internal table <lt_paxxxx>. Iam fillling <lt_paxxxx> in the following way.
    select * into table <lt_paxxxx> from (infty-dbname).
    I have to pass data of <lt_paxxxx> to another internal table lt_final.
    'lt_final' should contain fields like <lt_paxxxx>, infty name, DB name.
    Could you please help me out how to pass <lt_paxxxx> data to 'LT_FINAL'.

    loop at <it_table>
           into <is_table>.
        loop at it_fieldcatalog
             into is_fieldcatalog.
          assign component is_fieldcatalog-fieldname
                 of structure <is_table>
                 to <field1>.
          concatenate 'IT_TABLE-'
                              is_fieldcatalog-fieldname
                             into w_field.
         assign (w_field) to <field2>.
         check sy-subrc eq space.
          move <field1> to <field2>.
        endloop.
       append it_table
      endloop.
    regards

  • Distinct values from dynamic internal tabls

    Hi All,
    I have a dynamic internal tables like <dy_table> , i want to get distinct  values from this internal tables,
    how to do that, structure of dynamic internal tables is dynamic acc. to user conditions.
    regards,
    Anuj

    Hi Anuj
    Just try this,
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = tb_fields_for_it
    IMPORTING
    ep_table = gp_dyn_table.
    ASSIGN gp_dyn_table->* TO <gt_table>.
    ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <fs_table>.
    LOOP AT tb_output.
    *To assign value for serial number.
    ASSIGN COMPONENT 1 OF STRUCTURE <fs_table> TO <ls_field>.
    <ls_field> = tb_output-sno.
    UNASSIGN <ls_field>.
    *To assign value for Sales Organization.
    ASSIGN COMPONENT 2 OF STRUCTURE <fs_table> TO <ls_field>.
    <ls_field> = tb_output-vkorg.
    UNASSIGN <ls_field>.
    *To assign Rate for its respective Condition type.
    LOOP AT tb_konp WHERE knumh = tb_output-knumh.
    READ TABLE tb_fieldcat1 WITH KEY fieldname = tb_output-kschl.
    IF sy-subrc EQ 0.
    lv_count = tb_fieldcat1-col_pos.
    ASSIGN COMPONENT lv_count OF STRUCTURE <fs_table> TO <ls_field>.
    IF tb_konp-konwa EQ '%'.
    tb_konp-kbetr = tb_konp-kbetr / co_10.
    <ls_field> = tb_konp-kbetr.
    ELSE.
    <ls_field> = tb_konp-kbetr.
    ENDIF.
    ENDIF.
    ENDLOOP.
    lv_count = lv_count + 1.
    APPEND <fs_table> TO <gt_table>.
    CLEAR <fs_table>.
    ENDLOOP.
    Hope this proves helpful to you.

  • How to delete data from dynamic internal table

    Hi,
    I have dynamic internal table and I have some slection screen fields , using these selection screen fields
    (select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
    and also delete will not work for dynamic table..
    as we cannot use assigning with delete..
    So how to do this?
    and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
    so now after selection of data, I need to filter the data from dynamic table.
    Is there any way to do this?
    Regards,
    Mrunal

    Hi matt,
    I tried with below code as  you said. But I am getting dump. can you help?
    here is my piece of code.
    FIELD-SYMBOLS: <LS_DATA> type any,
                               <LT_DATA> TYPE table,
                                <L_FIELD> type any.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
    LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
    ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BUKRS.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BELNR.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ENDLOOP.
    and here is the description of my dump:->>>
    You attempted to access an unassigned field symbol
    (data segment 32772).
    This error may occur for any of the following reasons:
    - You address a typed field symbol before it is set using ASSIGN
    - You address a field symbol that points to a line in an internal table
      that has been deleted
    - You address a field symbol that had previously been reset using
      UNASSIGN, or that pointed to a local field that no longer exists
    - You address a global function interface parameter, even
      though the relevant function module is not active,
      that is it is not in the list of active calls. You can get the list
      of active calls from the this short dump.

  • Data from dynamic internal table to be downloaded to App server

    Dear Friends,
    I have a a dynamically generated internal table  and it contains huge data.And my requirement is to download the same data with a deliminator into a text file in application server.
    Can you pls help me with the code....
    Thanks,
    jeevan.

    Hello Jeevan,
    PFB a code snippet for your requirement:
    DATA: v_dataset TYPE fileextern VALUE './test335.txt',
          v_dref TYPE REF TO data,
          v_data TYPE string.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <wa> TYPE ANY,
                   <val> TYPE ANY.
    CREATE DATA v_dref TYPE STANDARD TABLE OF ('T001').
    ASSIGN v_dref->* TO <itab>.
    SELECT * FROM ('T001') INTO TABLE <itab> UP TO 20 ROWS.
    OPEN DATASET v_dataset FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    CHECK sy-subrc = 0.
    LOOP AT <itab> ASSIGNING <wa>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <val>.
        IF sy-subrc = 0.
          CONCATENATE v_data <val> INTO v_data SEPARATED BY ';'.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      TRANSFER v_data TO v_dataset.
      CLEAR v_data.
    ENDLOOP.
    CLOSE DATASET v_dataset.
    @Others: The OP wants to add a delimiter to the fields of a dynamic table.
    >
    jeevan kumar wrote:
    > I have a a dynamically generated internal table  and it contains huge data.And my requirement is to download the same data with a deliminator into a text file in application server.

  • How to delete records from dynamic internal table.

    Hi Experts,
    Need urgent help!!!
    Issue is with Dynamic internal tables.
    Below is code written by me :
    FORM select_query USING Lw_tabnam
                      TYPE  t682i-kotabnr.
      DATA :  lw_line  TYPE REF TO data,
              lw_line1 TYPE REF TO data.
        CREATE DATA Lw_line    TYPE (lw_TABNAM).
        ASSIGN      Lw_line->* TO   <WA_tbl>.
        CREATE DATA LW_LINE    TYPE STANDARD TABLE OF (Lw_tabnam)
                               WITH NON-UNIQUE DEFAULT KEY.
        ASSIGN      Lw_line->* TO <TBL>.
        SELECT * FROM  (Lw_tabnam)
                 INTO CORRESPONDING FIELDS OF TABLE <TBL>
                 WHERE (t_keys).
    Endform.
    code is working fine.
    here even the table name and where condition are dynamic,everything is fine upto this point.
    Now i have to delete some record from <TBL> based on some conditons.
         for ex : ( here lc_fieldname is KUNNR)
          loop at t_kunnr.
              lw_tabix = sy-tabix.
            Read table <tbl>
                    with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
            If sy-subrc = 0.
            *Delete
            delete <tbl> from <wa_tbl>
    delete <tbl> index  lw_tabix.
            Endif.
         Endloop.
    The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
    Can you help me ab't how to delete records in Dynamic internal table?
    Other option that i am thinking of is to create a static table of type dynamic table.
    means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
    Thanks in advance ,
    If you have any suggestion ab't this then do let me know.
    bye,
    Gaurav.

    Hi
    I wrote this code and it works fine:
    DATA LW_TABNAM(10) VALUE 'LFA1'.
    DATA : LW_LINES TYPE REF TO DATA,
           LW_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <TABLE> TYPE TABLE,
                   <WA>    TYPE ANY.
    CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN LW_LINES->* TO <TABLE>.
    CREATE DATA LW_LINE TYPE (LW_TABNAM).
    ASSIGN LW_LINE->* TO <WA>.
    DO 10 TIMES.
      APPEND INITIAL LINE TO <TABLE>.
    ENDDO.
    SY-TABIX = 4.
    DELETE <TABLE> INDEX SY-TABIX.
    WRITE SY-SUBRC.
    I hope it help you
    Max

Maybe you are looking for