Operation on internal table

Dear experts,
I have 2 internal table , 1 inernal table have 4 fields and 10 records in that and the other hv 3 fields and 10 records in each field in that . My task is to transfer the 4th field and records of that of 1st table to 2nd field. Need some help on that..
Table 1 Table 2
fields- F1 F2 F3 F4 I1 I2 I3 I4
A1 B1 C1 D1 A1 P1 Q1
A2 B2 C2 D2 A2 P2 Q2
A10 B10 C10 D10 A10 P10 Q10
Here i want records of f4 in i4. Is insert syntax is the way or any other way we can insert the data from table 1 to table 2.
Loop at Internal table1 into worka area1.
modify Internaltable2 from work area1 transporting internaltable2-2nd filed = work area1-4th field.
endloop.
i tryed with the above  query but i am getting the following error.
"No component exist with the name internaltable2-2nd filed".
Thanks And regards.
Sumeet
Moderator Message: Duplicate question from a different ID => Double Trouble.
Edited by: kishan P on Mar 1, 2011 2:15 PM

REPORT  ZTEST.
DATA: BEGIN OF IT_TBL OCCURS 0,
        LINE TYPE I,
      END OF IT_TBL.
DATA: LV_CNT TYPE I.
DO 20 TIMES.
  LV_CNT = LV_CNT + 1.
  IT_TBL-LINE = LV_CNT.
  APPEND IT_TBL.
ENDDO.
delete it_tbl INDEX 5.
delete it_tbl INDEX 7.
delete it_tbl INDEX 12.
LOOP AT IT_TBL.
  WRITE: / IT_TBL-LINE.
ENDLOOP.

Similar Messages

  • Set operations on Internal tables.

    Hi,
      Last week i had to enhance a program that has a internal table with some records. I need to find populate a table with the records in the internal table. But before populating i must find out the difference in the records (i.e) the extra records in the internal table compared with the records in the database table and then i have to append those records in the internal table again and then insert the internal table records into database table. while doing it i need to create another internal table with records in database table and then loop at it to find the extra records and rest of the logic goes on.
      At this point of time it clicked in my mind "WHY DON'T WE HAVE SET OPERATIONS ON TWO INTERNAL TABELS(UNION, INTERSECTION, MINUS)".
      Now i am doing some study how to implemnt it. Before that i want to find out whether that functionality exists in ABAP or anybody of youo gurus have done similar work on it.
    Pls help me in proceeding with my work.

    Hi Arul,
    There is no special aided SET operations upon internal tables in ABAP. Concerning your particular task I would say that you can try INSERT statement for each record in your internal table without preliminary comparing them with DB table. If there is a record in DB table with the same key then sy-subrc after INSERT will be non zero (actually 4) and no real insert would occur. So, only those records would be inserted which have no counterpart in DB table.
    Best regards, Sergei

  • String operations in internal table

    Dear friends..
            Good morning.
                        I wish to know.. how i segregate the field from a database table to internal table into two different internal table field. say for example.
    i have db table tab1 which has field number
    tab1 -> number
    and i have another internal table itab1 whic has two fields numa and numb
    tab1 -> numa
         -> numb
    i have value in tab1->number is 001 and 0001
    i wish to segregate this two values in to internal table
    if the value is 001 then it should be into 001 -> numa
    if the value is 0001 then it should be into 0001-> numb
    i dont know how to perform the string operations in internal table.. would you like to tell me how i fix this problem any suggetion, article, code will be great help of mine..
    thanking you
    Regards
    Naim

    Hi,
      what u can do is check the lenth
    lit_data_tab.
    lit_data_3
    lit_data_4.
    lv_char3 type char3.
    lv_char4 type char4.
    lv_length type i.
    loop at lit_data_tab.
    lv_length = STRLEN ( lit_data_tab-value ).
    if lv_length = 3.
       lv_char3 = lit_data_tab-value .
       append lv_char3 to lv_char3 type char3.
    else.
       lv_char4 = lit_data_tab-value .
       append lv_char4 to lv_char3 type char4.
    endif.
    endloop.
    if u want
    numa  numb
    003   0003.
    then u have to loop in one table and modify other.
    that is any one table should contains both the field.
    read the table with one field
    mark helpfull answers
    Regards
    Message was edited by: Manoj Gupta

  • How to perform aritmetic operations on interna table's fields ?

    i have an internal table containing entries from ekpo table.
    while displaying the internal table's entries i would like to add the field containing net price for the same po numbers.
    so, how do i perform arithmetic operations on this itab ? plz help..

    HI,
    see this example.
    u can do like this.
    DATA: BEGIN OF seats OCCURS 0,
            carrid   TYPE sflight-carrid,
            connid   TYPE sflight-connid,
            seatsocc TYPE sflight-seatsocc,
          END OF seats.
    DATA seats_tab LIKE HASHED TABLE OF seats
                   WITH UNIQUE KEY carrid connid with header line.
    SELECT carrid connid seatsocc
           FROM sflight
           INTO table seats.
    loop at seats.
      COLLECT seats INTO seats_tab.
    endloop.
    LOOP AT seats_tab.
    write:/ seats_tab-carrid,seats_tab-connid,seats_tab-seatsocc.
    ENDLOOP.
    rgds,
    bharat.

  • Date operations with internal table

    Dear friends
               would you like to tell me. how i determine the most recent date and time from internal table i am not supposed to sort the table by date and time... I must check date and time with other records date and time to determine which record is most recently changed...
    here the scenario is.
    id       idnumber  chdate      chtime
    1        123456    20060606    135312
    2        123456    20060606    135900
    3        123456    20060606    132300
    4        123457    20060606    140000
    5        123457    20060606    142500
    in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
    the record should be fetched this way
    id       idnumber  chdate      chtime
    3        123456    20060606    132300
    5        123457    20060606    142500
    because here the id 3 is the most recently changed in the idnumber 123456
    where id 5 is the most recently changed in the idnumber 123457
    please help me to determin how i am supposed to carry out this task  any suggestion, code will be great help of mine.
    regards
    Naim

    Hi Naim,
      For example if ur select statement is like this..
       select id idnumber chdate chtime from xtable into table itab  where ...<condn>..
        sort itab by  idnumber chdate chtime  descending.
         delete adjacent duplicates from itab comparing idnumber .
         Code like above statement..
       You can get result...
    id idnumber chdate chtime
    3 123456 20060606 132300
    5 123457 20060606 142500
      Reward the points if it helps.

  • String operations on internal table text....

    Original table is consists of 2 columns:
    E        
    RFC error(SM_DHTCLNT010_READ): Error when opening connection
    E RFC error(SM_DHLCLNT010_READ): Error when opening connection
    E RFC error(SM_DHKCLNT010_READ): Error when opening connection
    E RFC error(SM_E10CLNT000_READ): 'tdhtci00.emea.gdc:sapgw02' E     No read RFC FOR SM_B72CLNT003_READ
    E     No read RFC FOR SM_B71CLNT003_READ
    S     Clients for system 'E21' found in RFC  'SM_E21CLNT001_READ'
    S     Clients for system 'E22' found in RFC  'SM_E22CLNT001_READ'
    S     Clients for system 'E23' found in RFC  'SM_E22CLNT001_READ'
    Now we need to apply string operations such that result table is 3 columns with new refined message:
    status       sid            
    Message NEW_TEXT
    E     DHT         
    RFC error               Error when opening connectionE     DHL         RFC error                       Error when opening connection
    E     DHK         RFC error                       Error when opening connection
    E     E10       RFC error                      tdhtci00.emea.gdc:sapgw02
    E     B72        No RFC LINK
    E     B71        No RFC LINK
    S     E21        DATA READ
    S     E22       DATA READ
    S     E23       DATA READ
    String conditions to arrive at new table is:
    1) to get SID column : the conditions are
    •     If the Status is “RFC Error” then next 3 Characters after the “_” must be extracted as SID
    •     Else the SID is between the first and the second inverted comma ‘
    Example:  Clients for system 'E21' found in RFC  'SM_E21CLNT001_READ'extracts “E21” as SID
    2) for message column
    ·         message “RFC Error” if the message text
    starts with “RFC Error”
    · message “no RFC Link” if the message text starts with “No read RFC*”
    · message “Data Read” if the Substring “found in RFC”</b> was found in the Message      
    3) •     If the Status is “RFC Error” then the whole Textstring behind the “: “ must be Extracted
    For example if message is RFC error(SM_DHLCLNT010_READ): Error when opening connection NEW_TEXT will be Error when opening connection
    Need ur inputs on these.
    Bset regards,
    Subba

    Hi,
    this u can acheive simply using offset:
    var_name+off(len). "
    e.g. wa_message-fld+0(3) = first threee characters
    wa_message-fld(3) same as above first three characters
    wa_message-fld+2(2) " will display second and third characte of wa_message-fld
    this u can use to set condtions like :
    if wa_message-fld(9) = 'RFC Error'.
    "process here
    endif.
    Hope this will help u...
    Jogdand M B

  • Finding duplicates:Minus set operator in dealing with internal tables

    Dear experts,
    I am newbie to ABAP developement,i have been given an assignment to find the duplicate list of vendors in lfa table.
    Now duplicate list doesnot means that text tokens will be just exact to conclude them as duplicate ,it could also be like
    1111 Vendor ABC
    1222 ABC Vendor
    If anybody has clue ,how to work on such a problem ,plz come forward.
    Right now i just tried initially how to find exact duplicates,i found  on change command,it do works.
    Then i am trying a new way which should just do the same thing.
    I did as per this algorithm
    1.Compute wholesome list in one internal table itab1
    2.Used delete adjacent duplicates in itab2.
    3.I feel itab3=itab1-itab2 will contain all duplicates in itab3.
    Can anyone give me a hint.How can i do A-B ?.

    Hi Arul,
    There is no special aided SET operations upon internal tables in ABAP. Concerning your particular task I would say that you can try INSERT statement for each record in your internal table without preliminary comparing them with DB table. If there is a record in DB table with the same key then sy-subrc after INSERT will be non zero (actually 4) and no real insert would occur. So, only those records would be inserted which have no counterpart in DB table.
    Best regards, Sergei

  • Date sorting in internal table

    Dear Friends
       I wish to know how i perform the date operations in internal table... I am looking for the most recent record from the internal table for that i am supposed to look at chdate and chtime fields gives me the information on most corrently changed record... if  in the case of the record which is there but not changed to determin the its most currentness i must look at the crdate and crtime..so i have the code for that which works perfectly nice without the crdate and crtime... if i insert the crdate and crtime it gives me the only those records which are most currently chnaged according to chdate and chtime...would you like to help me in  this regards, I am giving you the code here.. any suggestion or changes will be great help of mine... thanking you,,,,
    regards naim... the code:
    TYPES: BEGIN OF itab_type,
            id       TYPE i,
            idnumber TYPE i,
            chdate   LIKE sy-datum,
            chtime   LIKE sy-uzeit,
            crdate   LIKE sy-datum,
            crtime   LIKE sy-uzeit.
    TYPES: END OF itab_type.
    DATA: itab     TYPE TABLE OF itab_type WITH HEADER LINE,
          itab_new TYPE TABLE OF itab_type WITH HEADER LINE,
          prev_rec TYPE itab_type.
    DATA: v_id TYPE i.
    START-OF-SELECTION.
      itab-id       = 1.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      itab-crdate   = '00000000'.
      itab-crtime   = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 2.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135900'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 3.
      itab-idnumber = 123456.
      itab-chdate   = '00000000'.
      itab-chtime   = '000000'.
      itab-crtime    = '20060622'.
      itab-crdate    = '125412'.
      APPEND itab. CLEAR itab.
      itab-id       = 4.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '140000'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 5.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '142500'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 6.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      itab-crdate    = '00000000'.
      itab-crtime    = '000000'.
      APPEND itab. CLEAR itab.
      itab-id       = 7.
      itab-idnumber = 123457.
      itab-chdate   = '00000000'.
      itab-chtime   = '000000'.
      itab-crdate    = '20060601'.
      itab-crtime    = '150000'.
      APPEND itab. CLEAR itab.
      itab_new[] = itab[].
      SORT itab_new BY idnumber ASCENDING
                       chdate DESCENDING
                       chtime DESCENDING
                       crdate Descending
                       crtime Descending.
      DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.
    LOOP AT itab.
         WRITE:/ itab-id,
                 itab-idnumber,
                 itab-chdate,
                 itab-chtime,
                 itab-crdate,
                 itab-crtime.
      ENDLOOP.
    skip 5.
    write: '_______________________________________________________________________________________'.
      LOOP AT itab_new.
        WRITE:/ itab_new-id,
                itab_new-idnumber,
                itab_new-chdate,
                itab_new-chtime,
                itab_new-crdate,
                itab_new-crtime.
      ENDLOOP.

    Hi,
    i modifed your code now see...,Copy paste and see...
    REPORT  ZTESTT                                  .
    TYPES: BEGIN OF itab_type,
    id TYPE i,
    idnumber TYPE i,
    chdate LIKE sy-datum,
    chtime LIKE sy-uzeit,
    crdate LIKE sy-datum,
    crtime LIKE sy-uzeit.
    TYPES: END OF itab_type.
    DATA: itab TYPE TABLE OF itab_type WITH HEADER LINE,
    itab_new TYPE TABLE OF itab_type WITH HEADER LINE,
    prev_rec TYPE itab_type.
    DATA: v_id TYPE i.
    START-OF-SELECTION.
    itab-id = 1.
    itab-idnumber = 123456.
    itab-chdate = '20060606'.
    itab-chtime = '135312'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 2.
    itab-idnumber = 123456.
    itab-chdate = '20060606'.
    itab-chtime = '135900'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 3.
    itab-idnumber = 123456.
    itab-chdate = '00000000'.
    itab-chtime = '000000'.
    <b>itab-crdate = '20060622'. "here you intechanged the data
    itab-crtime = '125412'.</b>
    APPEND itab. CLEAR itab.
    itab-id = 4.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '140000'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 5.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '142500'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 6.
    itab-idnumber = 123457.
    itab-chdate = '20060606'.
    itab-chtime = '135312'.
    itab-crdate = '00000000'.
    itab-crtime = '000000'.
    APPEND itab. CLEAR itab.
    itab-id = 7.
    itab-idnumber = 123457.
    itab-chdate = '00000000'.
    itab-chtime = '000000'.
    itab-crdate = '20060601'.
    itab-crtime = '150000'.
    APPEND itab. CLEAR itab.
    itab_new[] = itab[].
    SORT itab_new BY
    idnumber
    *chdate DESCENDING
    *chtime DESCENDING
    crdate Descending
    crtime Descending.
    DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber crdate
    crtime.
    *DELETE ADJACENT DUPLICATES FROM itab_new COMPARING idnumber.
    LOOP AT itab.
    WRITE:/ itab-id,
    itab-idnumber,
    itab-chdate,
    itab-chtime,
    itab-crdate,
    itab-crtime.
    ENDLOOP.
    skip 5.
    LOOP AT itab_new.
    WRITE:/ itab_new-id,
    itab_new-idnumber,
    itab_new-chdate,
    itab_new-chtime,
    itab_new-crdate,
    itab_new-crtime.
    ENDLOOP.
    Regards
    vijay

  • Internal table modifications

    hello gurus,
    I got output of a report as bellow.
    sl no       date                name           state         contry
    1            10.10.2009                         mtm
    1             10.10.2009     A1                   
    1            10.10.2009                                               abc 
    1            10.10.2009    b1
    1            10.10.2009    c1
    but my required output is.
    sl no       date                name           state         contry
    1            10.10.2009      A1                   mtm     ABC
    1             10.10.2009    B1                   
    1            10.10.2009     C1                                           
    can any body tell me how to change the format.
    my internal table data contains  as displayed output only.
    so i need to do operations at internal table level to get the required output.
    thanks,
    padmaja.
    Edited by: padmaja vaddi on Mar 9, 2009 5:09 AM

    Hi Padmaja,
    Please see the code below:
    itab1[ ] = itab[ ].
    sort itab1 comparing date name.
    delete adjacent duplicates from itab1.-->itab1 will contain 3 records and itab will contain 5 records
    loop at itab1 into wa_itab1.
    clear: wa_itab2, wa_itab.
    loop at itab into wa_itab where date = wa_itab1-date
                                     name = ' '.
    if wa_itab-state is not initial.
    wa_itab2-state = wa_itab-state.
    endif.
    if wa_itab-country is not initial.
    wa_itab2-country = wa_itab-country.
    endif.
    endloop.
    wa_itab2-name = wa_itab1-name.
    wa_itab2-date = wa_itab1-date.
    wa_itab2-sl_no = wa_itab1-sl_no.
    append wa_itab2 to itab2.
    endloop.
    And in the internal table itab2 , u will have the required output.
    Keerthi.

  • Good practices for ECC 6.0 wr.t. internal tables..

    hi,
    i am told that when defining internal tables in ecc 6.0, we shud avoid using OCCURS and WITH HEADER LINE.  and always use work areas..
    is this right ? is this a good practice or a must ?
    i followed this and created an internal table without a header line .then i  am using a collect statement in my programn which fails and says that IT is not with header line !!
    COLLECT ITT.
    what to do ?
    thks

    Yes, that is correct.  SAP is pushing the use of ABAP Objects and you can not use OCCURS or HEADER LINEs in the ABAP OO context.  You should always defined explicitly and a work area.
    Data: itab type table of mara.
    Data: wa like line of itab.
    So then you must keep this in mind when doing any operations on internal tables, like in the case of the COLLECT statement, the syntax would be.
    wa-field1 = '1'.
    wa-field2 = '2'.
    Collect wa into itab.
    Regards,
    Rich Heilman

  • How to join several internal tables?

    Hi,
    I have several internal tables. And there is a very complex LOOP to extract data from these internal tables and many other logic inside it. The LOOP is very time-consuming.
    I am thinking to join these internal tables into one big internal table, to save some logic inside the complex LOOP. But as I know there is no "join" function for internal tables.
    So is there any workaround method to perform a "join" operation on internal tables?
    Thanks a lot!

    Hi,
    I have several internal tables. And there is a very complex LOOP to extract data from these internal tables and many other logic inside it. The LOOP is very time-consuming.
    I am thinking to join these internal tables into one big internal table, to save some logic inside the complex LOOP. But as I know there is no "join" function for internal tables.
    So is there any workaround method to perform a "join" operation on internal tables?
    Thanks a lot!

  • Differenr types of internal tables

    hi gurus,
    what are the ineternal tables in xi.
    Thanks & Regards,
    priya

    Hi Priya
    Internal Tables Concept will be in ABAP.I think There are no Internal Tables in Xi.Internal tables are the tables which are used to fetch the data from standard SAP tables.Bcoz every time if u have access to database and if any operations perform on that tables data may be lost and the data maynot be consistent.So to maintain Data Consistent in Standard SAP tables we will use Internal tables mainly.
    If u want perform any operations on Internal tables u can perform like UPDATE,DELETE,MODIFY,INSERT,SORT...etc.
    Data will be populated in internal tables through Work Area.
    Before defining Internal table we have to define Work Area.
    DATA : BEGIN OF WA_EMP,
               EMPID(6) TYPE C,
               EMPNAME TYPE STRING,
               SAL TYPE I,
              END OF WA_EMP.
    DATA : T_EMP LIKE STANDARD TABLE OF WA_EMP.
    WA_EMP-EMPID = 'CO07'.
    WA_EMP-EMPNAME = 'JAMESBOND'.
    WA_EMP-SAL = '123456'.
    APPEND WA_EMP TO T_EMP.
    Thanks
    Pavan

  • Internal Table Operation Help Required

    Hi
    I have to insert 8 counters p1-p8 in a field BANFN of ITAB1.
    Like this their are 3 more fileds.I have to show the no. for PR released frm JAN-DEC in ALV format.I had doen the calualation,but unable to insert these conters in ITAB1 to do final calculation & display the result.
    Please help me.
    I had used : insert p1 into itab1-banfn where sy-index 1.
    Like this I had tried out many comands,but al in vain.PLZ help me in this regard.
    Regards.
    Vipin

    There are 8 fileds in my internal table,in which 1st one is for MONTH(JAN-DEC).
    The ALV is only suppose to display 12 rows,containing each month per row.
    Now for each month I have to display the PR converted to PO & the avg lead time for each month.So I had calu all the data ,but now I have to insert 12 counters in 4 fields.one for No of PR converted to PO in each month,than one for AVG LEAD TIME for each month.so there has to be 12 + 12 counters for each row.Similar operation I have to perform for the PR pending fo PO.So there has to be 24 more counters for again 2 diff fileds.Now I had calcuated the data,but the problem is this ,,,,,how to insert each ctr in each row.
    EG: insert ctr1 into itab1-banfn where itab1-mmyy = 'January' or sy-index = 1.
          insert ctr2 into itab1-banfn where itab1-mmyy = 'Febuary' or sy-index = 2.
          move crt1 to itab1-banfn where sy-index = 1.
    None of the operation is working.
    Like this i have to insert 48 counters in all rows for these 4 diff fileds.
    Pl help me in thsi regard ,if possible.
    regards.

  • Internal Table Line Operations - Collect Statement

    Hello Gurus,
    I have an internal table with data in it. The fields of the internal table are
    Location - Matnr - Qty - Flag.
    Same material can be at different locations with different quantities. I need to get material and total quantity of the material in all the locations in a new internal table.
    If the table (it_tab) contains -
    Location - matnr - qty - flag
    1200        abc       10    S
    1201        abc       20    S
    1205        abc       30    S
    1207        abc       50    S
    1200        xyz       20    S
    1201        xyz       25    S
    1300        xyz       22    S
    From this table, I need to get the result int table (it_res) as below -
    Matnr - qty
    abc      110
    xyz       67
    110 = 102030+50
    67 = 252220
    My idea is we can use collect statement looping the it_tab table.
    Please help me how to do this.
    Regards,
    Balu

    Hi balu,
    1. Simple
    2. Create one another internal table STAB,
        with only two fields
       a) MATNR
       b) QTY
    3. Now,
    4.
    Loop at Itab.
    Move-corresponding itab to STAB.
    COLLECT STAB.
    Endloop.
    regards,
    amit m.

  • Internal table operations

    Hi all,
       Please tell me the alternative of using loop that is specified in Bold. some body saying that is an alternative of using some statement without using loop in loop.
    * data declaration
    DATA: BEGIN OF T1 OCCURS 0,
    F1 TYPE I,
    END OF T1.
    DATA: BEGIN OF T2 OCCURS 0,
    F1 TYPE I,
    F2(10) TYPE C,
    END OF T2.
    DATA: T3 LIKE T2 OCCURS 0 WITH HEADER LINE.
    * fill internal table T1
    T1-F1 =  10.
    APPEND T1.
    T1-F1 =  20.
    APPEND T1.
    T1-F1 =  30.
    APPEND T1.
    T1-F1 =  40.
    APPEND T1.
    * fill internal table T2
    T2-F1 =  10.
    T2-F2 = 'AA'.
    APPEND T2.
    T2-F1 =  10.
    T2-F2 = 'AB'.
    APPEND T2.
    T2-F1 =  10.
    T2-F2 = 'AC'.
    APPEND T2.
    T2-F1 =  20.
    T2-F2 = 'BA'.
    APPEND T2.
    T2-F1 =  20.
    T2-F2 = 'BB'.
    APPEND T2.
    T2-F1 =  30.
    T2-F2 = 'CA'.
    APPEND T2.
    T2-F1 =  30.
    T2-F2 = 'CB'.
    APPEND T2.
    T2-F1 =  30.
    T2-F2 = 'CC'.
    APPEND T2.
    T2-F1 =  40.
    T2-F2 = 'DA'.
    APPEND T2.
    CLEAR: T1, T2.
    * fill internal table T1
    LOOP AT T1.
    <b>  LOOP AT T2 WHERE F1 = T1-F1.
        APPEND T2 TO T3.
      ENDLOOP.</b>
    ENDLOOP.
    * display internal table T1
    LOOP AT T3.
      WRITE:/ T3-F1, T3-F2.
    ENDLOOP.

    HI
       I guess for this case, there is no alternative statements as you have data in two internal tables. But
    YES you can minimise during extraction via FOR ALL ENTRIES.
    Eg:
    tables: mara.
    select-options: s_matnr for mara-matnr.
    types: begin of t_mara,
             matnr like mara-matnr,
             mtart like mara-mtart,
           end of t_mara.
    types: begin of t_marc,
             matnr like marc-matnr,
             werks like marc-werks,
           end of t_marc.
    data: it_mara type standard table of t_mara,
          it_marc type standard table of t_marc.
    select matnr mtart into table it_mara
           from mara
           where matnr in s_matnr.
    select matnr werks into table it_marc
           from marc
           for all entries in it_mara
           where matnr = it_mara-matnr.
    Kind Regards
    Eswar

Maybe you are looking for