‎2008 Sep 02 8:32 AM
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
‎2008 Sep 02 8:36 AM
‎2008 Sep 02 8: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
‎2008 Sep 02 8: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
‎2008 Sep 02 8:37 AM
‎2008 Sep 02 8: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
‎2008 Sep 02 8: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