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: 

Delete single row from DBTAB

Former Member
0 Kudos

Hi Experts,

I want to delete a single row from DBTAB ( KLAH )

WHERE KLAHKLART = '2' and KLAHCLINT = '241'.

Please advice

Karthik

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi ,

Try this code To delete single record from DB table- -

DATA : t_klah LIKE TABLE OF klah,
       fs_klah LIKE klah.
SELECT * FROM klah INTO TABLE t_klah
               WHERE klart = '2' AND
                     clint = '241'.
LOOP AT t_klah INTO fs_klah.
  DELETE klah FROM fs_klah .
  EXIT.
ENDLOOP.

Regards

Pinaki

8 REPLIES 8

former_member181962
Active Contributor
0 Kudos

Hi Karthik,

Deleting data from a standard table is not advisable.

Please search the forum before posting your query.

YOu can type the delete statement in your abap editor and press f1 on it.

YOu can get the usage of the delete statement for DBTABs

Regards,

Ravi

Former Member
0 Kudos

hi karthik,

Try the below code

data : wa_klah type klah.

select single * from klah into wa_klah where KLAHKLART = '2' and KLAHCLINT = '241'.

delete klah from wa_klah.

Thanks,

Vamshi

former_member226203
Active Contributor
0 Kudos

DELETE statement is not recomended for usage on standard tables

Former Member
0 Kudos

Hi ,

Try this code To delete single record from DB table- -

DATA : t_klah LIKE TABLE OF klah,
       fs_klah LIKE klah.
SELECT * FROM klah INTO TABLE t_klah
               WHERE klart = '2' AND
                     clint = '241'.
LOOP AT t_klah INTO fs_klah.
  DELETE klah FROM fs_klah .
  EXIT.
ENDLOOP.

Regards

Pinaki

0 Kudos

Press F1 on delete statement.

Former Member
0 Kudos

To all who replied with a piece of code to do the deletion: and what happens with the records in the other database tables that are related to the deleted KLAH record?

Former Member
0 Kudos

As others mentioned deleting data from database table is not recomended.

If you are pretty sure then you can try this way.

data: lv_tabix type sy-tabix.
select single * from klah into wa_klah 
where KLAH~KLART = '2' and KLAH~CLINT = '241'.
lv_tabix = sy-tabix.
delete klah index lv_tabix.

Regards,

Lalit Mohan Gupta.

Former Member
0 Kudos

Hi,

I am not advising you for deletion of data of standard table as it is not the standard process.

In case of emergency you can use delete command. But I must say you have to first consult your scenario

with SAP(SAP Online Portal) than only use delete command.

Regards,

Himanshu