This sounds simple but I've seen this done (in production boxes) a few times.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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