Problem solve Get help with specific problems with your technologies, process and projects.

Speeding up table deletes

This sounds simple but I've seen this done (in production boxes) a few times.

When you delete an entry from an internal table in ABAP, the system has to re-generate the index for all entries after your delete, slowing the report if you have many records to eliminate.

It is much quicker to do an insert of the correct records into a second table than to delete entries from the first. The reason for this is because the index is only generated for the newest element.

I've included the code below as an example where we achieved a 150X speed improvement. By removing the code that performs a delete on table th_vlpma and replacing it with an append to th_vlpmatmp, we were able to get these type of gains.


 *--- D01K919273 Begin delete 
*--- Delete deliveries not to be processed
*  loop at th_vbuk.
*    delete th_vlpma where vbeln eq th_vbuk-vbeln.
*  endloop.                             " th_vbuk.
*--- D01K919273 End delete
*--- Begin add D01K919273
   loop at th_vlpma into th_vlpmatmp.
      read table th_vbuk with key vbeln = th_vlpmatmp-vbeln
         binary search.

      check sy-subrc ne 0.
      append th_vlpmatmp.
   endloop.    
*--- End add D01K919273      

This was last published in March 2001

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close