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: 

More Secured way of Delete

former_member194669
Active Contributor
0 Kudos

Hi All,

I need to write a program delete some of the entries from custom table. These are info related to table

1. Average number of records : 5 to 7 million records

2. Number of records to be deleted per day : 10000 to 15000

3. Number of records to be going to update per day 20000 to 25000

I like to know which is the best way to delete and update records from this table?

I looking the best syntax to delete / update

Thanks

aRs

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Hi Rob,

Thanks for your reply.

But in your reply you specified that don't use modify is specific reason to that?

Thanks

aRs

8 REPLIES 8

Former Member
0 Kudos

Hi,

Best way is put all records to an internal table and then either delete or update.

syntax is: UPDATE <Ztable>FROM TABLE <ITAB>

DELETE <target> FROM TABLE <itab>

ferry_lianto
Active Contributor
0 Kudos

Hi aRs,

You can use delete statement to delete entries from custom table.

DELETE <custom table> FROM TABLE ITAB.

and use MODIFY statement to update the records for custom table. This command will create a record if does not exits and update database if exists already in the database.

MODIFY <custom table> FROM TABLE ITAB.

Regards,

Ferry Lianto

Former Member
0 Kudos

Can't really say without knowing a bit more about the requirements.

Will you be deleting all of the records at once or one at a time?

Will you be updating all of the records at once or one at a time?

Rob

former_member194669
Active Contributor
0 Kudos

Hi Rob,

I am updating/delete all records at once,

This custom table have T table associated with it.

Thanks

aRs

0 Kudos

I would select all of the records that you want to delete into an internal table. Then

DELETE  dbtab      FROM TABLE itab

Handle INSERTS AND UPDATES the same way. Don't use MODIFY.

Rob

ferry_lianto
Active Contributor
0 Kudos

Hi aRs,

To delete all records at once, you use standard program RADCVBTC.

OBJ_NAME = <ztable>

OBJ_TYPE = 'TABL'

FCT = 'MDF'

To update all records at once, you can use the OPEN CURSOR, FETCH and CLOSE_CURSOR statements. Don't forget specify the package size.

Here is an example code.

PACKAGE_SIZE = P_SIZE.

OPEN CURSOR WITH HOLD CURS FOR

SELECT *

FROM MARA

WHERE MATNR <> SPACE.

DO.

FETCH NEXT CURSOR CURS

INTO TABLE I_MARA PACKAGE SIZE PACKAGE_SIZE.

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

ENDDO.

CLOSE CURSOR CURS.

Hope this will help.

Regards,

Ferry Lianto

former_member194669
Active Contributor
0 Kudos

Hi Rob,

Thanks for your reply.

But in your reply you specified that don't use modify is specific reason to that?

Thanks

aRs

0 Kudos

If you use MODIFY, SQL has to determine whether to do an INSERT or UPDATE. If you know this in advance, you will save time by doing INSERTS and UPDATES instead.

Rob