Skip to Content
avatar image
Former Member

internal table operation info?

hi

please tell me that,if i had 25 records in an itab & i only want to read 1st 10 records,or to delete onwards 11th records,what can be the code.

please tell me.

regds

vipin

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Sep 02, 2008 at 07:36 AM

    Hello

    delete ITAB from 11.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:37 AM

    hi,

    To read first of 10 records and delete record from 11th and onword.

    loop at (itab) .
    
    READ TABLE itab index sy-tabix.
    
    write: itab-field1,
             itab-field2,
             itab-field3,
             .
             .
             .
             .
             .
    
    if sy-tabix gt 10.
       delete itab index sy-tabix.
    endif.
    
    endloop.

    regards,

    anirban

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:37 AM

    Hi,

    loop at itab from 1 to 10

    move itab to itab1.

    endloop.

    delete itab.

    Regards,

    Harish

    Edited by: Harish Kumar on Sep 2, 2008 1:08 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:37 AM

    Hi Dude,

    DELETE itab FROM 11.

    Hope this helps u.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 07:41 AM

    Hi

    U should use the index in order to read or delete a certain record:

    
    N = 10.
    * Reading
    DO   N    TIMES.
      READ TABLE INTAB INDEX N.
      IF SY-SUBRC = 0.
        WRITE: / 'Read record nr.:', SY-INDEX.
      ENDIF.
    ENDDO.
    
    N = 11.
    * Deleting (all records from 11th)
    DO .
     DELETE ITAB INDEX N.
     IF SY-SUBRC <> 0. EXIT. ENDIF.
    ENDDO.
    
    

    Max

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 02, 2008 at 07:50 AM

    hi

    check this code

    TYPES : BEGIN OF ty_itab,
           a TYPE i,
           b TYPE i,
           END OF ty_itab.
    
    DATA : wa_itab TYPE ty_itab,
           it_itab TYPE TABLE OF ty_itab.
    
    
    DO 25 TIMES.
    
      wa_itab-a = sy-index.
      wa_itab-b = sy-index + 1.
      APPEND wa_itab TO it_itab.
    
    ENDDO.
    
    LOOP AT it_itab INTO wa_itab.
      READ TABLE it_itab INTO wa_itab INDEX sy-tabix.
      WRITE : / wa_itab-a , wa_itab-b.
      IF sy-tabix GE 10.
        DELETE itab INDEX sy-tabix.
      ENDIF.
    ENDLOOP.

    With Regards.

    Always Learner

    Add comment
    10|10000 characters needed characters exceeded