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 database table entries through program

Former Member
0 Likes
130,956

Hi,

My requirement is to delete database table entries where datum <> sy-datum. how to implement this.

Thanks in advance.

Naseer.

1 ACCEPTED SOLUTION
Read only

Former Member
38,163

Hi,

In the report u can write statement like this,

DELETE FROM <your table>

WHERE date = sy-datum.

if u excute this report then those records will be deleted from your database table.

reward points if useful,

seshu.

3 REPLIES 3
Read only

kiran_k8
Active Contributor
38,163

Naseer,

Try using SE16N,with that we can delete the entries of Ztable for sure but for SAP standard table I am not sure.

K.Kiran.

Read only

Former Member
38,164

Hi,

In the report u can write statement like this,

DELETE FROM <your table>

WHERE date = sy-datum.

if u excute this report then those records will be deleted from your database table.

reward points if useful,

seshu.

Read only

Former Member
38,163

Hi Naseer,

Don't delete the data from the table directly until unless if it is a stand alone table (no relationship exist with any other table).

if that table is updating from any Tcode then you have to delete the data from Tcode only, even though you have a facility to delete from the table, in real time there may be a chance of dependency, which will not suggestible.

if it is a Ztable which was created by you, then make sure that there is no relationship with another table, then only go for "Delete from table where coditions XXXXXX", even this is not suggestible, if it is a Ztable create table maintenance for that then do the operations you want.

More information regarding delete is

DELETE dbtab

Syntax

DELETE { {FROM target WHERE sql_cond}

| {target FROM source} }.

Effect

The statement DELETE deletes one or more rows from the database table specified in target. The rows that are to be deleted are specified either in a WHERE condition sql_cond or with data objects in source.

System Fields

The statement DELETE sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning

0 A least one row was deleted.

4 At least one row could not be deleted, since it was not found in the database table.

The statement MODIFY sets sy-dbcnt to the number of deleted rows.

Note

The rows are deleted permanently from the database table in the next database commit. Until then, you can cancel the deletion in a database rollback.

Still More info about delete statment

If u have ABAP editor then type "delete".place the cursor on it and click on help(F1) ,u can get the all options regarding delete.

if u want to delete the table

DELETE FROM MARA.

if u want to delete the table entries.

DELETE MARA FROM WA.

here WA contains the entries which u want to delete.

DELETE MARA FROM TABLE ITAB.

here ITAB contains the entries which u want to delete from the table MARA.

Regards,

Chandru