Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
yassine_abid
Explorer

Hi all,

I would like to share this algorithm with you because it's very simple and can solve a big issue.

We want to optimize this statement:

Delete itab where f1 =v1 and ... and fn = vn.

For every occurrence of (v1, ..., vn) we have n comparisons so if we have loop and delete statements, the complexity is m * n (m is the size of table used in loop).

we can reduce number of comparison to log(n) if we do like this :

sort itab by f1 f2 .. fn.

do.

     read table itab with key f1 = v1 ... fn = vn binary search transporting no field.

     if sy-subrc eq 0.

          delete itab index sy-tabix.

     else.

          exit.

     endif.

enddo.

eg: this algorithm reduce 2 000 000 000 comparisons to 22 comparison.

best regards,

Yassine ABID

1 Comment