delete rows in ABAP

Question: Hai..

i have one question in loop. From the following code i am trying to delete material from certain number.. but i am trying to do with this one its throwing dump..

Could sombody told me best process..

TABLES: mara.

DATA: i_mara LIKE mara OCCURS 0 WITH HEADER LINE.


SELECT * FROM mara INTO TABLE i_mara.


LOOP AT i_mara.

IF i_mara-matnr < '000000000000000090'.


DELETE i_mara INDEX sy-tabix.
MODIFY i_mara.

ENDIF.

ENDLOOP.


thnaks..

Answer:
Hi,

Why dont u just select the entries that you want to delete into the internal table ?

Eg.


tables: mara.
data: i_mara type mara occurs 0 with header line.
select * from mara into table i_mara where matnr < '000000000000000090'.
delete mara from table itab.


I think this is what u want to do right ? If not please clarify. I have assumed u want to delete those entries from the database.
_________________
Live Life King Size

Answer:
Hai..\\

Thanks for reply... i dont want to delete materials from mara.. ..

Answer:
Hello,

If u r not wanting to delete from the DB then I guess the

select * from mara into table i_mara where matnr < '000000000000000090'.

statement is enough right ? That should be what u want. No need to select all entries into the internal table and delete which is not needed. Instead just select what u want

Bye
_________________
Live Life King Size

Answer:
Although the alternative mentioned with the matnr in a SELECT statement is perfect to get the correct data . , the best process on shortdumps is to go into debug mode and sort out the problem. Try pressing F1 on the statements involved and see what you are actually trying to achieve.

DELETE i_mara INDEX sy-tabix.
MODIFY i_mara.

The DELETE can do without the sy-tabix, it will then delete the current line. The shortdump is after the DELETE where the MODIFY tries to update the current line . This current line has just been deleted and the
MODIFY dumps as it miss any reference to a current line. The MODIFY is in this case totally unnecessary anyway . so comment it out and it will work.
Another alternative is to do an DELETE ... WHERE matnr ... statement to clean up your itab in 1 go.
Oh and never never never hardcode variables.
_________________
Only sheep and Tuly Idiots need a leader

Answer:
TABLES: mara.

DATA: i_mara LIKE mara OCCURS 0 WITH HEADER LINE.
data : l_index type sy-tabix.

SELECT * FROM mara INTO TABLE i_mara.


LOOP AT i_mara.
l_index = sy-tabix.

IF i_mara-matnr < '000000000000000090'. (as this statement makes sy-tabix 0 )


DELETE i_mara INDEX l_index.
MODIFY i_mara.

ENDIF.

ENDLOOP.

with regards ,
Nitesh shelar
Copyright ?2007 - 2008 www.jt77.com