Skip to Content
avatar image
Former Member

Combine Info from two itab

Hi,

WHAT IS THE WAY U FOLLOW TO COMBINE INFORMATION FROM TWO-ABAP DICTIONARY TABLE INTO A SINGLE INTERNAL TABLE (EXCEPT JOINING)? SPECIFY THE METHOD.WHAT R THE NECESSARY PRECAUTIONS NEEDS TO BE TAKEN WHILE USING THAT STATEMENT?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Aug 22, 2007 at 06:47 AM

    Except JOIN you can have data in two seperate internal tables and then loop the first itab, READ the second and pass the data into third itab.

    <b>select * from tab1 into table itab1.

    select * from tab2 into table itab2.

    loop at itab1 into wa1.

    READ table itab2 into wa2 with key fld1 = wa1-fld1.

    <move data to final itab>

    endloop.</b>

    Regards,

    Amit

    Reward all helpful replies

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Select data from first database table into first internal table,

      use for all entries to select the data from second table .

      loop at first internal table read second internal table using read statement n append the data into third internal table.

      regards,

      Prashant

  • avatar image
    Former Member
    Aug 22, 2007 at 09:39 AM

    Hai,

    Instead of using the joins u can use for all entries. When u r using the for all entries u should check two conditions.

    1.driver table is sorted or not.

    2.driver table is empty or not.

    eample of this code.

    data : it_vbap like vbap occurs 0 with header line.

    data : it_vbak like vbap occurs 0 with header line.

    select *

    from vbak

    into it_vbak.

    if not it_vbak[] is in initial.

    select * from vbap

    into it_vbap

    for all entries in it_vbak

    where vbeln eq it_vbak-vbeln.

    endif.

    Reword the points if it is helpful.

    Thanks and Regards,

    P.N.Reddy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 01:07 PM

    select *

    from DB1

    into IT1

    where<condition>.

    if not it1[] is in initial.

    sort it1 by <key>.

    delete adjacent duplicates from IT1 comparing <key>.

    select * from DB2

    into IT2

    for all entries in IT1

    where <key> = IT1-<key>.

    endif.

    loop at IT2 assigning <fs2>.

    read table IT1 assigning <fs1> with key <key> = <fs2>-key binary search.

    if sy-subrc = 0.

    copy fields into workk area w3 from <fs1 & <fs2>.

    append wa3 to IT3.

    clear wa3.

    endif.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 22, 2007 at 01:12 PM

    Hi Basu

    take data from one table into one internal table

    and use FOR ALL ENTRIES for second select stmt with first internal table....

    reward points to all helpful answers

    kiran.M

    Add comment
    10|10000 characters needed characters exceeded