01-15-2007 4:57 AM
Hi All,
How to delete a row from a table i mean which function or command to use?
say for example.
i have a table which is sorted in descending order.
and i do loop at that table.
whenever sy-tabix will be 3 then i need to delete that particular row from that table.
please tell me how can i do this?
Thanks,
Vijaya.
01-15-2007 5:00 AM
Hello Vijaya,
Use the delete statement.
DELETE itab INDEX sy-tabix to delete from the internal table.
DELETE dbtab FROM wa_itab to delete from the database table.
Manoj
01-15-2007 5:01 AM
Hi,
Delete that particular record using the statement.
Delete <Field> index sy-tabix.
It will delete the current field in that loop.
Regards,
Ram
Pls reward points if helpful
01-15-2007 5:02 AM
01-15-2007 5:04 AM
Hi,
read table itab into wa index 3.
if sy-subrc eq 0.
delete from db where keyfield1 = wa-keyfield1
and keyfield2 = wa-keyfield2.
endif.
01-15-2007 5:07 AM
Hi,
suppose internal table is i_internal.
you can loop at this table and check for sy-tabix.
for ex.
loop at i_internal.
if sy-tabix eq '3'.
delete i_internal.
endif.
endloop.
(Reward helpful queries)
Regards,
Siddhesh Sanghvi.
01-15-2007 5:18 AM
Hi
Try like this.
I have executed this and working fine.
loop at itab into wa.
if sy-tabix = 3.
delete mara from wa.
endif.
*write : / wa-matnr.
endloop.
Thanks
Shiva
01-15-2007 5:27 AM
Hello,
i am not sure what you want to do. If you loop at a itab and want to delete a row from dbtab where sy-tabix eq 3. then check the code given below.
REPORT zmadhu_exp.
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE mara.
DATA: END OF itab.
data: tabix like sy-tabix.
data: var like sy-tabix.
SELECT * FROM mara
INTO CORRESPONDING FIELDS OF TABLE itab UP TO 10 ROWS.
LOOP AT itab.
tabix = sy-tabix.
tabix = tabix + var.
if tabix eq 3.
var = 1.
DELETE itab.
delete itab from dbtab.
commit work.
endif.
ENDLOOP.
this way you only delete 1 row from itab and subseqent row from dbtab.