Application Development and Automation 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: 
Read only

Delete single row from DBTAB

Former Member
0 Likes
3,035

Hi Experts,

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

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

Please advice

Karthik

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,134

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
Read only

Former Member
0 Likes
2,134

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

Read only

Former Member
0 Likes
2,134

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

Read only

Former Member
0 Likes
2,134

DELETE statement is not recomended for usage on standard tables

Read only

Former Member
0 Likes
2,135

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

Read only

0 Likes
2,134

Press F1 on delete statement.

Read only

Former Member
0 Likes
2,134

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?

Read only

Former Member
0 Likes
2,134

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.

Read only

Former Member
0 Likes
2,134

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