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

Deleting the Data from Data base table

Former Member
0 Likes
1,286

Hi,

I am deleting the data from Data base table.In Dev system as we have very less records, my program is worling fine.

But in Quality system, it is failing why because huge amont of data is present in Data base table.

My Basis team advised me that Delete the records in group and COMMIT the data base table.

Can we delete some 1000 records and COMMIT the data base table and again can we delete some 1000 records and COMIIT the data base table so that we can reduce the load on Server.

If yes,

How can we put Delete Statement in Loop statement.

Would you please advise me on this.

10 REPLIES 10
Read only

Former Member
0 Likes
1,195

Check whether you can use perform .. on commit or update function module for this task.

Thanks,

Aravind

Read only

0 Likes
1,195

HI Arvind,

Thank You for your reply. We dont have any Perform On Commit or Update Function Module.

Read only

0 Likes
1,195

Yes, you can do a delete <dbtab> from <internal table>....

I do mass updates to a non-production system, but not deletes, but it works like this: I have a package size on screen (type I).....

select * from [dbtable name] into [internal table of same type as dbtable]
package size p_pkg "(from screen parameter)
where....(any appropriate where clause).

* do any necessary logic to figure out what to keep or discard from internal table.

Delete [dbtable name] from [internal table].

endselect.

Note: COMMIT is not needed....

Run single-thread...NOT in parallel, since you can get deadlocks from having multiple executions simultaneously!

Edited by: BreakPoint on Mar 15, 2011 1:30 PM

Read only

0 Likes
1,195

Have a look at the ABAP help on DELETE dbtab.

Should give you an idea how to delete per a certain amount of records.

Read only

0 Likes
1,195

hi

just write the below code...

select * from [dbtable name] into [internal table of same type as dbtable]

where....(any appropriate where clause).

loop at internal table into work area.

delete dbtable from work area.

endloop.

it will deleted the selected data base table entries.

Regards

ksardar

Read only

0 Likes
1,195

Ksardar, you copied my post as your own work?! And, didn't even change the words! And, then provided a MUCH SLOWER way to accomplish the same delete process!

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,195

Are you deleting the whole database table, then DELETE is not the fastest way, you could delete and recreate the table from ddic definition.

Look at FM like [MCS_BIW_DROP_CREATE_TABLE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=mcs_biw_drop_create_table] or manage it yourself with [DB_STORAGE_SAVE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=db_storage_save], [DD_DROP_TABLE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=dd_drop_table], [DD_GET_NAMETAB|http://www.sdn.sap.com/irj/scn/advancedsearch?query=dd_get_nametab] and [DD_CREATE_TABLE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=dd_create_table].

Regards,

Raymond

Read only

AlexanderOv
Product and Topic Expert
Product and Topic Expert
0 Likes
1,195

You might need to make an index for your table if you are using following command

DELETE FROM ... WHERE ...

Read only

ThomasZloch
Active Contributor
0 Likes
1,195

How much is "huge amount"? How exactly is it "failing", what error message / short dump are you seeing?

Do you want to delete the entire table contents in all clients (see Raymond's reply), or just selected entries?

Thomas

Read only

0 Likes
1,195

Actually, now i'm curious about the table itself: what's the name of the table you need to delete?