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

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply