Skip to Content
avatar image
Former Member

how to insert reocrords into ab table using conditions

Hi Gurus,

I got a requirement to insert 100 records into an table from an internal table which contains 10000 records. this should be done 2 times i.e 1st 100 records first then the 2nd 100 records.i am not intrested in the rest of the records.so how can i write the insert stament for this? can anyone tell me plz.

Regards,

Ravi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Oct 17, 2008 at 06:18 AM

    Hi,

    Try this...

    Loop at itab.

    if sy-tabix <= 100.

    insert table.

    endif.

    endloop.

    Regards,

    Dhan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2008 at 06:34 AM

    hi, what do you mean by "i am not interested in the rest records". if they are not useful to you , you can just delete the rest records and then insert the whole internal table.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2008 at 07:12 AM

    hi,

    u will have to loop at the internal tabel and on the basis of some condition insert that selected data to the table.

    do the following :

    IT_A-internal table taht contains data.

    FINAL - ztable where data is to be inserted.

    data wa_final type ztable.

    loop at IT_A into WA_A.

    if <condition>.

    move WA_A to wa_final.

    insert wa_final to FINAL.

    clear wa_final.

    endif.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2008 at 09:02 AM

    Hi,

       flag = 0.
    
       loop at it_tab.
       if flag <=100.
        ------insert into it_final table
       flag = flag + 1.
       endif.
       endloop.
    
    *---for inserting next 100
    if flag > 100 and flag <=200.
      loop at it_tab.
       if sy-index <= 100.
        ------insert into it_final table
       flag = flag + 1.
       endif.
       endloop.
    endif.
    

    Thanks ,

    Krishna...

    Add comment
    10|10000 characters needed characters exceeded