Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

internal table operation info?

Former Member
0 Likes
685

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

6 REPLIES 6
Read only

Former Member
0 Likes
655

Hello

delete ITAB from 11.

Read only

Former Member
0 Likes
655

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

Read only

Former Member
0 Likes
655

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

Read only

Former Member
0 Likes
655

Hi Dude,

DELETE itab FROM 11.

Hope this helps u.

Read only

Former Member
0 Likes
655

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

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
655

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