Combining two internal table

Hi,
Can any one tell how to combine two internal tables??

hi,
data it_tab  like table of wa_struct.
data it_tab2 like table of wa_struct.
it_tab-field1 = "a".
append it_tab.
it_tab2-field2 = "b".
append it_tab2.
move-correponding   it_tab to it_tab2.
or
data it_tab3 like table of wa_struct.
loop at it_tab.
it_tab3-field = it_tab -field.
append it_tab3.
endloop.
loop at it_tab2.
it_tab3-field = it_tab2-field.
append it_tab3.
endloop.
regards,
Siva
REGARDS,
Siva.

Similar Messages

  • Combining Two Internal Tables??

    How do you combine two internal tables(not by append statement)...if any one knws please let me know..thanks in advance..

    Sort itab_vbap by vbeln posnr.
    sort itab_vbkd by vbeln posnr.
    Loop at itab_vbap into wa_vbap.
    read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.
    if sy-subrc = 0.
    move corresponding wa_vbap to wa_final.
    move corresponding wa_vbkd to wa_final.
    append wa_final to itab_final.
    endif.
    endloop.
    For move corresponding statement the name of the fields should match in both the work areas.
    I hope it helps.

  • Processing two internal tables

    hi
    i have two internal tables
    itab1  with feilds  partner, vbeln. cmgst ( SO status)
    itab2  - vbeln, posnr(item no ), kwmeng(qunatity) , cmpre ( credit price )
    now i need to get the sum of  (cmpre * kwmeng) for each partner and SO status combination into another internal table itab3.
    so itab3 will have partner, cmgst (so status ) , total amount
    is it possible to achieve this with out using loop inside a loop.
    thanks

    Hi Sudhakar,
    Check below code sample. Change it according to ur need.
    DATA: BEGIN OF itab1 OCCURS 0,
          partner TYPE string,
          vbeln TYPE vbeln,
          cmgst TYPE cmgst,
          END OF itab1,
          wa1 LIKE itab1.
    DATA: BEGIN OF itab2 OCCURS 0,
          vbeln TYPE vbeln,
          posnr TYPE posnr,
          kwmeng TYPE kwmeng,
          cmpre TYPE cmpre,
          END OF itab2,
          wa2 LIKE itab2.
    DATA: BEGIN OF itab3 OCCURS 0,
          partner TYPE string,
          cmgst TYPE cmgst,
          amt TYPE p DECIMALS 2,
          END OF itab3,
          wa3 LIKE itab3.
    wa1-partner = 'Test1'. wa1-vbeln   = '0000000001'. wa1-cmgst   = 'X'.
    APPEND wa1 TO itab1. CLEAR wa1.
    wa1-partner = 'Test2'. wa1-vbeln   = '0000000002'. wa1-cmgst   = 'X'.
    APPEND wa1 TO itab1. CLEAR wa1.
    wa2-vbeln  = '0000000001'. wa2-posnr  = '000001'. wa2-kwmeng = 10. wa2-cmpre  = 100.
    APPEND wa2 TO itab2. CLEAR wa2.
    wa2-vbeln  = '0000000002'. wa2-posnr  = '000002'. wa2-kwmeng = 20. wa2-cmpre  = 200.
    APPEND wa2 TO itab2. CLEAR wa2.
    LOOP AT itab1 INTO wa1.
      READ TABLE itab2 INTO wa2 WITH KEY vbeln = wa1-vbeln.
      IF sy-subrc = 0.
        wa3-partner = wa1-partner.
        wa3-cmgst   = wa1-cmgst.
        wa3-amt     = wa2-kwmeng * wa2-cmpre.
        APPEND wa3 TO itab3.
        CLEAR wa3.
      ENDIF.
    ENDLOOP.
    Thanks,

  • Using for all entries of two internal tables in where clause of the select

    Hi experts,
    My requirement is, need to select Marc-minbe and wrpl-sobst, for all the entries of the two internal tables it_mara , and it_t001w.
    here is the select queries i have used,
    select matnr normt from  mara into it_mara for all entries in it_data where normt = it_data-normt.
    select konnr werks from t001w into it_t001w for all entries in it_data where konnr = it_data-konnr.
    now i need to select minbe of marc table and sobse of wrpl table for all the entries of above internal tables, it_mara and it_t001w, using both matnr of it_mara and werks of it_t001w in where condition.
    Pls advise how i can do it.
    Thanks.
    Moderator message: very basic, please work on this yourself first, these forums are not a substitute for ABAP training.
    Edited by: Thomas Zloch on Dec 6, 2010 9:38 AM

    Hi
    call SE16 with table TFTIT in order to get a full list (it will be long...)
    A list of FMs with parameters can be found in table FUNCT.
    Finally go to sm37rsdf4
    that will give you all the function modules with description
    Here is the list:
    http://www.erpgenie.com/abap/functions.htm
    hope this helps...
    Regards
    CSM Reddy

  • Comparing each value of two internal tables

    HI  everybody,
    i have two internal tables  itab1 and itab2 same structure
    both r having four fields each and field with values
    now i need to compare the two internal tables
    and if every value of itab1 matches itab2
    then i have to write one select quirie  for the following given description
    compare past and current shipping point
    compare internal_table2 and internal_table3
    if entry in internal_table2 and internal table3 match
    variable_tknum = internal_table2-tknum
    endif.
    for each entry that matches:
    select vlabdata into zi_vlabdata from vlbl where vbeln = variable_tknum and vlbl-vlabtyp = 'ZIBOOKNO'.
    plz give me solution for this
    thanks
    hridhayanjili.

    sort : ITAB1 by f1,f2,f3,f4,
           ITAB2 by f1,f2,f3,f4.
    LOOP AT ITAB1.
      READ TABLE ITAB2 WITH KEY F1 = ITAB1-F1
                                F2 = ITAB1-F2
                                F3 = ITAB1-F3
                                F4 = ITAB1-F4 BINARY SEARCH.
      IF SY-SUBRC = 0.
    *--all the fields of ITAB1 and ITAB2 are matching .
    *--write your logic here
      ELSE.
    *--ITAB1 and ITAB2 records are not matching.
      ENDIF.
    ENDLOOP.
    Regards
    Srikanth
    Message was edited by: Srikanth Kidambi

  • Reg  comparison of two  internal tables

    hi friends,
    please help me solving this.
    there are two internal tables t_zvs38 and t_value
    1.t_value like seahlpres
    2.t_zvs38 like zvs38.
    values in t_value will be like this.
    first line wil contain zmdtype(mandatory document) and second line will contain
    zmdtypet (the description for zmdtype).
    eg.
    D001 -
    -zmdtype
    internal----
    zmdtypet
    D002
    external
    D003
    renewal
    values in t_zvs38.
    for a particular sales.org the zmdtype is filled.
    select vkorg zmdtype into corrsponding fields of table t_zvs38
    where vkorg = p_vkorg.
    Now i want to compare t_value and t_zvs38 with field zmdtype
    and delete the contents of  t_value which are not in t_zvs38.
    i have written like this.
    loop at t_value.
    read table t_zvs38 with key zmdtype = t_value-string.
    if sy-subrc ne 0.
    delete t_value. "to delete zmdtype
    sy-tabix = sy-tabix + 1.
      delete t_value. " to delete zmdtypet
    else.
    sy-tabix = sy-tabix +2. "to go to next zmdtype.
    endif.
    endloop.
    but it is deleting all the contents of t_value.
    points are assured.

    CLEAR zvs32t.
      SELECT zvs32tzmdtype zvs32tzmdtypet
        INTO (zvs32t-zmdtype, zvs32t-zmdtypet)
        FROM zvs32t
        JOIN zvs32
        ON   zvs32tzmdtype = zvs32zmdtype
        WHERE zvs32t~spras    = sy-langu
        AND   zvs32~zfrenewal = space.
         WRITE zvs32t-zmdtype TO t_value.
        APPEND t_value.
        WRITE zvs32t-zmdtypet TO t_value.
        APPEND t_value.
      ENDSELECT.
      SELECT vkorg vkbur zmdtype FROM zvs38 INTO CORRESPONDING FIELDS OF TABLE t_zvs38
      WHERE vkorg = p_vkorg
    AND vkbur = p_vkbur.
      LOOP AT t_value INTO wa_area1.
        v_index = sy-tabix.
        READ TABLE t_zvs38 INTO wa_area2 WITH KEY zmdtype = wa_area1-string
      BINARY SEARCH.
       IF sy-subrc NE 0.
          IF l_flag IS INITIAL.
            DELETE t_value INDEX v_index.
           ELSE.
            CLEAR l_flag.
          ENDIF.
       ELSE.
          l_flag = 'X'.
       ENDIF.
      ENDLOOP.
    Using this code ,i am unable to ge the correct output.Thank u all for ur help.

  • Downloading two internal tables in same text file

    I have one internal table as like below.
    Data:begin of itab1 occurs 0,
         rec(5),
         end of itab1.
    Itab1 is getting updated from input text file(Continuous text).
    Here Itab1 contains one record with Indicator '01 and n number of records with indicator '02'.
    This needs to be seperated in to two internal tables.
    data:Begin of Itab_Head occurs 0,
         Rec_ind(2) type C,
         Name(3) type C,
         end of itab_Head.
    data:Begin of Itab_Item occurs 0,
         Rec_ind(2) type C,
         Id(3) type C,
         Status(10,
         end of itab_Item.
    loop at itab1.
    If itab1-Rec+0(2) = '01'.
       Itab_Head-Rec_Ind = itab1-rec+0(2).
       Itab_Head-Name = itab1-rec+2(3).
       Append Itab_Head.
    elseif itab1-rec+0(2) = '02'.
       Itab_Item-Rec_Ind = itab1-rec+0(2).
       Itab_Item-Id = itab1-rec+2(3).
       Append Itab_Item.
    endif.
    endloop.
    After moving to the internal tables I am doing some processing and updating the status of Itab_item.
    After all these again I have to download the internal table as a text file.Now my question is.
    I have values in 2 diff internal tables.How to download the two in same file.

    See this sample code.
    data: itab1 type string occurs 0 with header line,
          itab2 type string occurs 0 with header line.
    itab1 = 'itab1_text'.
    append itab1.
    itab2 = 'itab2_text'.
    append itab2.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        exporting
          FILENAME = 'C:\ftext.txt'
        APPEND = 'X'
        changing
         DATA_TAB = itab1[].
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        exporting
          FILENAME = 'C:\ftext.txt'
          APPEND = 'X'
        changing
         DATA_TAB = itab2[].
    Svetlin

  • Two internal tables in to one internal table

    Hi , 
               I have two internal tables ITAB1 and ITAB2, i would like to put fields from  two internal tables in to one internal table(ITAB3) with out using inner joint. any one of you can give the sample code for this
    Thanks
    Raja.

    Hi,
    Kamesh wrote :
          Read itab2 into wa_itab2 with key f2 = itab1-f1 <USe your where conditions here>.
    Read statement does not have WHERE conditions.
    Please be careful while posting. Your thread will be reffered by many people. Please dont mislead.
    Regards,
    Swapna.

  • Function module for comparing contents of two internal tables

    Hi All,
    Is there any function module to compare contents of two internal tables of same structure?
    If yes please let me know.
    Thanks in advance.
    Amol

    Hi
    call SE16 with table TFTIT in order to get a full list (it will be long...)
    A list of FMs with parameters can be found in table FUNCT.
    Finally go to sm37rsdf4
    that will give you all the function modules with description
    Here is the list:
    http://www.erpgenie.com/abap/functions.htm
    hope this helps...
    Regards
    CSM Reddy

  • Get the Common from Two Internal Tables with same structure

    Hi ,
    I need to get the Common data from Two Internal Tables with same structure with using the looping method.
    For e.g.
    I have two internal table say ITAB1 and ITAB2.
    ITAB1 has values A,B,C,D,E,F
    ITAB2 has values A,H,B,Y,O
    Output at runtime should be : A,B

    Hi mohit,
    1. If u want to compare all fields,
       for matching purpose,
       then we can do like this.
    2.
    report abc.
    data : a like t001 occurs 0 with header line.
    data : b like t001 occurs 0 with header line.
    loop at a.
      LOOP AT B.
        IF A = B.
          WRITE :/ 'SAME'.
        ENDIF.
      endloop.
    ENDLOOP.
    regards,
    amit m.

  • How to check two internal table fields

    Hi all,
    I need to check two internal table fields are equal or not means which statement i can use.
    Not internal table ,table contents i need to check i.e
    it1-pernr = it2-pernr.
    like this
    if i put loop it'll check one table field for one loop.
    if i put two loop means some fields reflecting 2 in it1 then it'll pring 4 times like that.i want to print whatever in internal table only .
    pernr(0001) two times there in it1 means
    it1-pernr = it2-pernr then
    it's printing
    0001
    0001
    0001
    0001
    like this but actually in it1 only two records.
    Anybody know solution.tell me.
    Thanks
    Regards,
    Nandha

    Hi,
    code for your view
    data : begin of it1 occurs 0,
           z_pernr like pa9012-pernr,
           z_fac_c like pa9012-zz_fac_c,
           end of it1.
    data : it2 like Zsc1 occurs 0 with header line,
    It1 data
    pernr   FAC C
    0001   5555
    0001   5555
    0002   4444
    0003   3333
    0006   8888
    It2 data
    pernr   FAC C
    0001   5555
    0001   5555
    0005   6666
    0003   3333
    output(My code)
    loop at it2 .
    loop at it1 where pernr = it2-pernr.
      write:/01 it1-1pernr,
            10 it1-z_fac_c.
    endloop.
    endloop.
    out put i need.
    0001   5555
    0001   5555
    0002   4444
    0003   3333
    Thanks,
    Nandha

  • Alv with two internal tables

    I have two separate internal tables. However , they have a common field matnr. In the report output, the two internal tables should be joined by this common field. Can this be done with an ALV . The common field Matnr should appear to the extreme left. Followed by itab1 and then itab2 . Its in a sense Matnr is the header , but it shows as rows. Each matnr has several item in both itab1 and itab2 , it is not necessary that total number of item data in itab1 and itab2 will be same .

    You can see example program :
    TYPE-POOLS: slis.
    DATA: BEGIN OF itab OCCURS 0,
            vbeln TYPE vbeln,
            expand,
          END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0,
            vbeln TYPE vbeln,
            posnr TYPE posnr,
            matnr TYPE matnr,
            netpr TYPE netpr,
          END OF itab1.
    DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
    DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
    s_fieldcatalog-col_pos = '1'.
    s_fieldcatalog-fieldname = 'VBELN'.
    s_fieldcatalog-tabname   = 'ITAB'.
    s_fieldcatalog-rollname  = 'VBELN'.
    s_fieldcatalog-outputlen = '12'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '1'.
    s_fieldcatalog-fieldname = 'VBELN'.
    s_fieldcatalog-tabname   = 'ITAB1'.
    s_fieldcatalog-rollname  = 'VBELN'.
    s_fieldcatalog-outputlen = '12'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '2'.
    s_fieldcatalog-fieldname = 'POSNR'.
    s_fieldcatalog-tabname   = 'ITAB1'.
    s_fieldcatalog-rollname  = 'POSNR'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '3'.
    s_fieldcatalog-fieldname = 'MATNR'.
    s_fieldcatalog-tabname   = 'ITAB1'.
    s_fieldcatalog-rollname  = 'MATNR'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    s_fieldcatalog-col_pos = '4'.
    s_fieldcatalog-fieldname = 'NETPR'.
    s_fieldcatalog-tabname   = 'ITAB1'.
    s_fieldcatalog-rollname  = 'NETPR'.
    s_fieldcatalog-do_sum    = 'X'.
    APPEND s_fieldcatalog TO t_fieldcatalog.
    CLEAR: s_fieldcatalog.
    DATA: s_layout TYPE slis_layout_alv.
    s_layout-subtotals_text            = 'SUBTOTAL TEXT'.
    s_layout-key_hotspot = 'X'.
    s_layout-expand_fieldname = 'EXPAND'.
    SELECT vbeln UP TO 100 ROWS
           FROM
           vbak
           INTO TABLE itab.
    IF NOT itab[] IS INITIAL.
      SELECT vbeln posnr matnr netpr
             FROM vbap
             INTO TABLE itab1
             FOR ALL ENTRIES IN itab
             WHERE vbeln = itab-vbeln.
    ENDIF.
    DATA: v_repid TYPE syrepid.
    v_repid = sy-repid.
    DATA: s_keyinfo TYPE slis_keyinfo_alv.
    s_keyinfo-header01 = 'VBELN'.
    s_keyinfo-item01   = 'VBELN'.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
         EXPORTING
              i_callback_program = v_repid
              is_layout          = s_layout
              it_fieldcat        = t_fieldcatalog
              i_tabname_header   = 'ITAB'
              i_tabname_item     = 'ITAB1'
              is_keyinfo         = s_keyinfo
         TABLES
              t_outtab_header    = itab
              t_outtab_item      = itab1
         EXCEPTIONS
              program_error      = 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.
    Thanks
    Seshu

  • Can we get the data from two internal tables in ALV.

    hi friends i would like to display the data using two internal tables using alv grid.please guide me.

    Hi,
    ALV would be having a specific layout say :
    MATNR
    MAKTX
    QTY
    Now, if you have two internal tables, then do they have a different structure. If they have different structures, then what kind of ALV layout you expect. The ALV output should be as per the structure of 1st or 2nd internal table.
    If both internal table have same layout, then populate the data from 2nd internal table into 1st internal table and pass the 1st internal table ( it will have data of both internal tables) to ALV.
    Best regards,
    Prashant

  • How to join two internal table rows in alternative manner into one internal table?

    How to join two internal table rows in alternative manner into one internal table?
    two internal tables are suppose itab1 &  itab2 & its data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    d
    e
    f
    g
    h
    i
    Header 1
    Header 2
    Header 3
    1
    2
    3
    4
    5
    6
    7
    8
    9
    INTO itab3 data
    Header 1
    Header 2
    Header 3
    a
    b
    c
    1
    2
    3
    d
    e
    f
    4
    5
    6
    g
    h
    i
    7
    8
    9

    Hi Soubhik,
    I have added two additional columns for each internal table.
    Table_Count - It represents the Internal Table Number(ITAB1 -> 1, ITAB2 -> 2)
    Row_Count  - It represents the Row Count Number, increase the row count value 1 by one..
    ITAB1:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    a
    b
    c
    1
    1
    d
    e
    f
    1
    2
    g
    h
    i
    1
    3
    ITAB2:
    Header 1
    Header 2
    Header 3
    Table_Count
    Row_Count
    1
    2
    3
    2
    1
    4
    5
    6
    2
    2
    7
    8
    9
    2
    3
    Create the Final Internal table as same as the ITAB1/ITAB2 structure.
    "Data Declarations
    DATA: IT_FINAL LIKE TABLE OF ITAB1.          "Final Internal Table
    FIELD-SYMBOLS: <FS_TAB1> TYPE TY_TAB1,     "TAB1
                                   <FS_TAB2> TYPE TY_TAB2.     "TAB2
    "Assign the values for the additional two column for ITAB1
    LOOP AT ITAB1 ASSIGNING <FS_TAB1>.
         <FS_TAB1>-TABLE_COUNT = 1.             "Table value same for all row
         <FS_TAB1>-ROW_COUNT = SY-TABIX. "Index value
    ENDLOOP.
    "Assign the values for the additional two column for ITAB2
    LOOP AT ITAB2 ASSIGNING <FS_TAB2>.    
         <FS_TAB2>-TABLE_COUNT = 2.                  "Table value same for all row
         <FS_TAB2>-ROW_COUNT = SY-TABIX.      "Index value
    ENDLOOP.
    "Copy the First Internal Table 'ITAB1' to Final Table
    IT_FINAL[] = ITAB1[].
    "Copy the Second Internal Table 'ITAB2' to Final Table
    APPEND IT
    LOOP AT ITAB2 INTO WA_TAB2.
    APPEND WA_TAB2 TO IT_FINAL.
    ENDLOOP.
    "Sort the Internal Table based on TABLE_COUNT & ROW_COUNT
    SORT IT_FINAL BY  ROW_COUNT TABLE_COUNT.
    After sorting, check the output for IT_FINAL Table, you can find the required output as shown above.
    Regards
    Rajkumar Narasimman

  • Compare two internal tables

    hi everybody
    i have two internal tables  ITAB1 AND ITAB2
    I WANT TO COMPARE THE CONTENTS OF THESE INTERNAL TABLES HOW TO DO THIS
    REGARDS
    HRIDHANJILI

    Hello Hridhayanjili
    The most detailed comparison is to use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:
    TYPES: BEGIN OF ty_s_itab_di. 
    INCLUDE TYPE struc_a.
    TYPES: CHIND  TYPE bu_chind.
    TYPES: END OF ty_s_itab_di.
    TYPES: ty_t_itab_di  TYPE STANDARD TABLE OF ty_s_itab_di
                         WITH DEFAULT KEY.
    DATA: 
      gt_itab_old  TYPE ty_t_itab_di, 
      gt_itab_new  TYPE ty_t_itab_di.
    Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.
    Very important: sort you itabs either by all key fields or by all fields.
    Call function CHANGEDOCUMENT_PREPARE_TABLES with the following parameters
    - CHECK_INDICATOR = ' '
    - TABLE_NEW = gt_Itab_new
    - TABLE_OLD = gt_itab_old
    The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'.
    Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.
    Regards
    Uwe

Maybe you are looking for