Appending internal tables.

Hello All,
Can any of you let me know
How can we append one internal contents to other when their structure do not match??
Is it possible? Or is there an other approach for this??
Thanks
Karthik Krishna

Hi Karthik,
there are two ways, it depends on your structures:
PROGRAM ZGRO_TEST MESSAGE-ID  ZZ LINE-COUNT 70.
TABLES: MARA.
DATA: BEGIN OF ITAB1 OCCURS 0,
      MATNR LIKE MARA-MATNR,
      GROES LIKE MARA-GROES,
      WRKST LIKE MARA-WRKST,
      END   OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 0,
      GROES LIKE MARA-GROES,
      WRKST LIKE MARA-WRKST,
      END   OF ITAB2.
SELECT * FROM MARA WHERE MATNR
              BETWEEN '000000000000016184' AND '000000000000016186'.
  ITAB1-MATNR = MARA-MATNR.
  ITAB1-GROES = MARA-GROES.
  ITAB1-WRKST = MARA-WRKST.
  APPEND ITAB1.
ENDSELECT.
LOOP AT ITAB1.
  MOVE-CORRESPONDING ITAB1 TO ITAB2. "First
ITAB2 = ITAB1.                    "second
  APPEND ITAB2.
ENDLOOP.
try both ways and look in itab2 where the differenc is.
Regards, Dieter

Similar Messages

  • Append Internal table?

    Hi all,
    I am fetching some data from a MARA table to internal table int_temp.
    again i am fetching some more records from MARA...here i want to append these records to the same internal table int_temp.
    how to do this...
    SAchin

    Hi,
    Use like :
    append lines of int_temp1 to int_temp2.
    Pls reward points if useful.
    Regards,
    Renjith Michael.

  • Appending internal table which is referenced by field-symbol

    Hi,
    I have a selection screen field called SP$00005 which is not known until runtime as the field is selected in Adhoc Query (SAP Query) by the user.
    In the customer exit I am attempting to write code to default in a range to this field - it is a date field and I want to enter the range 01.04.2007 - 30.04.2007.
    As select-options require the appending of the screen field table SP$00005 I need a way of adding an entry to this table.
    Please see my latest attempt below which appends the correct value to the field symbol <startdate> but this entry does not appear in the internal table SP$00005 when stepping through at runtime.
    Can anyone suggest a possible solution?
    Thanks,
    Alan
      data: ref_field(8) type c.
      field-symbols: <startdate> type table. "table = STANDARD by default
      types: begin of sp$00005, "type definition required for syntax check
                  sign(1),
                  option(2),
                  low type d,
                  high type d,
                end of sp$00005.
      data: lt_ref type ref to data.
      ranges: selection for sy-datum.
      ref_field = 'SP$00005'.
      create data lt_ref type table of (ref_field).
      assign lt_ref->* to <startdate>.
    assign (ref_field) to <startdate>. "- raises type error
      move 'I' to selection-sign.
      move 'BT' to selection-option.
      move '20070401' to selection-low.
      move '20070430' to selection-high.
      append selection to <startdate>.

    Hi,
    I tried the following which appends <startdate> with the new entry but the underlying referenced table SP$00005 is still not updated.
    Any ideas?
    Thanks,
    Alan
      field-symbols: <startdate> type any table,
                     <l_line> type any,
                     <l_field> type any.
      data: ref_field(8) type c.
      types: begin of sp$00005, "type definition required for syntax check
               sign(1),
               option(2),
               low type d,
               high type d,
             end of sp$00005.
      data: lt_ref type ref to data.
      ranges: selection for sy-datum.
      data: new_line type ref to data.
      ref_field = 'SP$00005'.
      create data lt_ref type table of (ref_field).
      assign lt_ref->* to <startdate>.
      create data new_line like line of <startdate>.
      assign new_line->* to <l_line>.
      if <l_line> is assigned.
    move values using assing stt.
      endif .
      move 'I' to selection-sign.
      move 'BT' to selection-option.
      move '20070401' to selection-low.
      move '20070430' to selection-high.
      assign selection to <l_line>.
      insert <l_line> into table <startdate>.

  • To populate data in a dynamic internal table

    Hi,
    I have an internal table <FS_1> which I have created dynamically. Now i need to populate the columns (7th column onwards) in the internal table with my data in GT_REQMT which is an internal table.
    Data: L_IDX type I.
    L_IDX = 6.
    Loop at <FS_1> assigning <FS_2>.
      If sy-tabix = 1.
        Loop at GT_REQMT.
         Add 1 to L_IDX.
    *****I need to populate GT_REQMT-DATA to column 7 then 8 etc depending on the number of loops.
         Modify <FS_1> from <FS_2>.
        Endloop.
      Else.
    **do other things here**
      Endif.
    Endloop.
    I have search through the forums and weblogs but the solutions are catered to populating the internal tables from SAP database using SQL statements.
    I couldn't find anything on populating own data in dynamic table by looping it. Please help. THANKS!!
    Cheers,
    Chelsea

    Hi!
    I have used classes for dynamic internal table, SO i here give you my sample code for your help.
    DATA : new_table TYPE REF TO data,
           new_line  TYPE REF TO data.
    FIELD-SYMBOLS : <TAB1> type standard table,
                    <l_table> TYPE ANY TABLE,
                    <l_line>  TYPE ANY,
                    <l_field> TYPE ANY.
        count = count + 1.
        clear wa_fieldcat.
        wa_fieldcat-col_pos   = count.
        wa_fieldcat-fieldname = 'CONDITION'.
        wa_fieldcat-coltext   = 'Condition Value'.
        wa_fieldcat-ref_field = 'KWERT'.
        wa_fieldcat-ref_table = 'KONV'.
        wa_fieldcat-outputlen = 13.
        append wa_fieldcat to it_fieldcat.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
         it_fieldcatalog = it_fieldcat
       IMPORTING
         ep_table        = new_table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    ASSIGN COMPONENT KWERT OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = t_kschlkonv-vtext.
    NOw u append internal table
    IF its helps you then dont forget to rewards points.
    Regards From
    Priyank

  • Passing of internal table values to the select statement as SETS

    Hi All,
    Is there any way that i can restrict the values of a internal table to be passed to a select statement set by set..
    say for eg: if a itab has 1000 entries i want the first 500 to be going out in a select statement as a comparision for all entries and then the next set of 500 to go out..
    Please let me know.. this is very urgent..

    <b>Appending Several Lines</b>
    You can also append internal tables to index tables using the following statement:
    APPEND LINES OF <itab1> TO <itab2>.
    This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
    When you append an index table to another index table, you can specify the lines to be appended as follows:
    APPEND LINES OF <itab1> [FROM <n1>] [TO <n 2>] TO <itab2>.
    <n 1 > and <n 2 > specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
    This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX contains the index of the last line appended. When you append several lines to a sorted table, you  must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
    Then u can use <b> FOR ALL ENTRIES</b> in select query.
    regards
    vinod

  • Regarding joining two internal tables

    Hi All,
    Tell me how to use 'UNION' in different ways.
    Thank you,
    Rohit

    Hi,
    If its internal table joining then best is to use APPEND LINES.... statement.
    You can also append internal tables to index tables using the following statement:
    APPEND LINES OF itab1 TO itab2.
    This statement appends the whole of ITAB1 to ITAB2. ITAB1 can be any type of table, but its line type must be convertible into the line type of ITAB2.
    When you append an index table to another index table, you can specify the lines to be appended as follows:
    APPEND LINES OF itab1 [FROM n1] [TO n2] TO itab2.
    n1 and n2 specify the indexes of the first and last lines of ITAB1 that you want to append to ITAB2.
    This method of appending lines of one table to another is about 3 to 4 times faster than appending them line by line in a loop. After the APPEND statement, the system field SY-TABIX
    contains the index of the last line appended. When you append several lines to a sorted table, you must respect the unique key (if defined), and not violate the sort order. Otherwise, a runtime error will occur.
    thanx.

  • CLEAR INTERNAL TABLE

    IN WHICH CONDITION CLEAR INTERNAL TABLE,APPEND INTERNAL TABLE  STATEMENT IS USED?

    hi,
    Normally we use clear statement immediately after using append statement... so as to clear the header of internal table ..
    loop at itab.
      itab1-field1 = itab-field.
      append itab1.
      clear itab1.
    endloop.

  • How to append  row in internal table for perticular condition

    Hi,
    I have 4 records in my internal table and i want to append row
    after second row when condition will match.
    please guide me.
    thanks in advancs
    regards
    SND

    hi,
    using key word INDEX u can insert a record in aspecified position as
    if internal table is with header line.
    INSERT <internaltable> index SY_INDEX [or index no if u  know where to insert]
    with out header line.
    INSERT <internaltable> FROM <workarea> index SY_INDEX [or index no if u  know where to insert]
    if condition is true.
    insert itab index 2.
    endif.
    if helpful reward some points.
    with regards,
    Suresh.A

  • How to append records between two internal tables

    hi all,
    im trying to append from an internal table to another internal table with same structure. i tried the following but it overwrites previous contents of i_dest:
    move i_src to i_dest
    thanks,
    sid

    hey u try to move it record by record
    <b>itab2 = itab.
    append itab2.</b>
    This should work I guess
    just check the code below, if u want to move the whole itab into itab2 then use <b>itab2[] = itab.</b>
    <b>loop at it_pgm.
      read table itab with key obj_name = it_pgm-pgm_name.
      if sy-subrc = 0.
        itab_final-obj_name = itab-obj_name.
        itab_final-func_spec = itab-func_spec.
        itab_final-func_area = itab-func_area.
        itab_final-dev_class = itab-dev_class.
        append itab_final.
    else.
       itab_alt-pgm_name = it_pgm-pgm_name.
       append itab_alt.
      endif.</b>
    please reward points if found helpful

  • Append data to internal table

    i m calling one FM inside the loop, this FM will return data in internal table. for each loop count i want to save this data to same other internal table, how to do that?
    i want to append the one internal tables data to another internal table how to do that?
    Thanks

    Hi Lucky,
                  Refer this code :
    LOOP AT I_TAB1.
      CALL FUNCTION <FUNCTION NAME>
          EXPORTING
          IMPORTING
          TABLES = I_TAB2.
      APEEND LINES OF I_TAB2 to I_TAB3.
      REFRESH I_TAB2.
    ENDLOOP.
    REWARD POINTS IF HELPFUL.
    Regards,
    Hemant

  • Append a record to internal table

    hello:
    when i execute the code below,there is a runtime error." In die sortierte interne Tabelle (Typ SORTED_TABLE)
      "PROGRAM=ZJOIN_INTER_TABLEDATA=T_ITAB1" sollte an
    Position 1 eine Zeile eingefügt bzw. geändert werden.
    Dadurch wurde die für die Tabelle durch ihren Schlüssel festgelegte
    Sortierreihenfolge zerstört."
    how can i resolve it?which one can tell me?Thanks very much
    REPORT  ZJOIN_INTER_TABLE.
    DATA:BEGIN OF WA_ITAB,
            COL1 TYPE I,
            COL2(10) TYPE C,
          END OF WA_ITAB.
    DATA:T_ITAB1 LIKE SORTED TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
    WA_ITAB-COL1 = 10.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.
    WA_ITAB-COL1 = 9.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.

    hi
    kindly go thro the lines.
    syntax:
    DATA itab {TYPE tabkind OF linetype|LIKE tabkind OF lineobj}
              WITH [UNIQUE|NON-UNIQUE] keydef
              [INITIAL SIZE n] [WITH HEADER LINE].
    The system creates an internal table with table type tabkind. Since there is no generic field definition, you cannot use the table types ANY TABLE or SORTED TABLE.
    The construction of the table lines is defined by linetype (if you are using a TYPE reference) or by the type of the referred object lineobj (if you are using a LIKE reference). If you specify the line type, you can also use REF TO to refer to a reference type.
    The same rules apply to UNIQUE and NON-UNIQUE as apply to the TYPES definition. You may only omit this specification with standard tables.
    If you do not specify an INITIAL SIZE, the system assumes a default value of INITIAL SIZE 0.
    i think now u r clear... now yr code will work.
    DATA:BEGIN OF WA_ITAB,
    COL1 TYPE I,
    COL2(10) TYPE C,
    END OF WA_ITAB.
    DATA:T_ITAB1 like TABLE OF WA_ITAB WITH NON-UNIQUE KEY COL1.
    WA_ITAB-COL1 = 10.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.
    WA_ITAB-COL1 = 9.
    WA_ITAB-COL2 = 'col2'.
    APPEND WA_ITAB TO T_ITAB1.

  • Appending All the fields of one internal table to other

    Hi,
    while running a FM I get three internal tables, my requirement is that I am running this FM at item level if it is possible to append all the tables datas get as a result of this FM to other internal table having same structure.
    I know it is possible while using loop, I need a solution with out using the loop
    Regards
    Nausal

    Move Itab1[] to itab2[].
    data: begin of itab occurs 0,
          Maktx LIKE MAKT-MAKTX,
      end of itab.
    data: begin of itab1 occurs 0,
          Maktx LIKE MAKT-MAKTX,
      end of itab1.
    select maktx from makt into table itab where maktx like 'M1%'.
    move itab[] to itab1[].
    loop at itab1.
      write:/ itab1-maktx.
    endloop.

  • Append two structures in an internal table.

    hi,
         if i join two tables by innerjoining will it effect the performance?If such,how i can join these with better performance?can i get the data from different tables in a single internal table by appending different structures in this case?Please answer me.

    If inner Join has a performance issue the best thing u can do is...
    Create 3 int tables.   "This is to avoid 'INTO CORRESPONDING FIELDS' select query which will affect performance.
    itab1 with the structure of table1
    itab2 with the structure of table2
    itab3 with the structure of table1 & table2
    Select from 1st table into itab1.
    if itab1 is not initial.
    select from table 2 into itab2 for all entries in itab1 where field = itab1-field.
    sort itab2 by field.   "For binary search
    loop itab1.
    move-corresponding itab1 to itab3.
    read itab2 with key field = itab1-field binary search.
    move-corresponding itab2 to itab3.
    append itab3.
    endloop.
    Regards
    Sathar
    Edited by: Sathar RA on Sep 8, 2008 9:10 AM

  • How to append Header of an internal table to another internal table

    Hello Experts,
    Can we append the header of an internal table to another internal table? Do we have have to use work area for this?
    Thanks.

    Wrong - it will append only the header. If you want to append the whole table, you would:
    APPEND LINES OF itab1 TO itab2.
    If you need more help, please press F1 on APPEND.
    Rob
    Edited by: Rob Burbank on Mar 3, 2008 4:06 PM

  • Effect of appending  standard internal table to hashed one ?

    hi,
    in my main program i have an internal table called NAST which is hashed. i call a function module which returns an internal table called xNAST, whose records i append to NAST. since i dealt with TABLES tab of FM, i had to receive this xNAST of type standard table (and not hashed).
    i appended the lines of xNAST to NAST using INSERT statement.
    Now at one point, i have a statement,
    READ TABLE *nast INTO *xxx WITH KEY mmm = '100'.
    so when i inserted the records into NAST from xNAST, they r automatically hashed, right ? and this statement will work without any issues ?
    thks

    Hello,
    WITH KEY
    For hashed tables, the hash algorithm is used if the specified search key includes the table key. Otherwise the search is linear. The addition BINARY SEARCH is not permitted for hashed tables.
    Alternative
    WITH TABLE KEY
    Effect:
    Each component of the table key must listed either directly as comp_name1 comp_name2 ..., or as a bracketed character-type data object name1 name2 ..., which contains the name of the component when the statement is executed (before release 6.10 in upper case). If name contains spaces only, this component specification is ignored when the statement is executed. A data object must be assigned to each component, which is compatible with or can be converted to the data type of the component. The first found line of the table is read, for which the values in the columns of the table key match the values in the assigned data objects dobj1 dobj2 .... If necessary, the content of dobj1 dobj2 ... is converted to the data type of the component before the comparison.
    The different table types are accessed as follows:
    standard tables are searched using a linear search.
    sorted tables are searched using a binary search.
    For hashed tables, the hash algorithm is used.
    Regards.

Maybe you are looking for

  • For some reason I cannot find where to attach a picture to an imessage on my MacBook Pro.  Can anyone tell me?

    For some reason I cannot find where to attach a picture to an imessage on my MacBook Pro.  Can anyone tell me?

  • Open Directory conection for Client inconsistant

    Hi, Been working setting up several labs during the summer and have come across a new problem.  When joining the computers to Open Directory the comptuers connect to the Replica and are added to the Open Directory list.  However, at the login screen

  • OC4j Developer Preview problem with JDBC

    I'm running the developer preview of OC4J (9.0.4) and trying to get a connection to SQL Server 2000 for my CMP 2.0 entity beans. I have a setup and configuration that works on Orion 2.0, but when I moved it over to OC4J it no longer worked. I get an

  • Hierarchical alv doesn't expand

    Hello  experts i written a hierarchical alv it run fines at output it doesn't expand please help me to find out the problem. REPORT  ZCR_HERARCHIAL_LIST_DISPLAY. TABLES :VBAK,VBAP. TYPE-POOLS:SLIS. DATA : BEGIN OF IT_VBAK OCCURS 0,        VBELN LIKE

  • External defination and namespace

    Hi, We have used external defination,that has a name space, as the source message. While pushing test data through an HTTP client, do the message require to have the namespace of the external defination. I know we have to include namespace for test d