Application Development 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: 

Deletion of a row from a DB table

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

DELETE FROM ztable WHERE qmnum GT '000000000000'.

COMMIT WORK.

jayanthi_jayaraman
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.