ABAP Overlapping Ranges or Select Options

Bit of an old-school ABAP question!

I have a report with two similar select-options on the selection screen, both type NUMC and 6 in length. I want the user to be free to enter number range(s) plus individual values, exclusions etc if they want to (ie. the normal ways you are able to populate a select-option). However the values in the two ranges must have no overlap or contradiction. Typical range for the first select-option would be 230000 – 249999 and for the second 500000-599999, but if the user entered 230000 – 249999 and 249000 – 259999 for example an error should be raised.

What I am looking for is an SAP standard function module (or similar) to which I could provide the two select-options and get it to check for any clashes. The only solution I have come up with so far is to expand the individual values into two (potentially massive) internal tables and then loop through one of them looking for a matching value in the other. My code for doing this with “BT” ranges looks like this:

    loop at s_voynr.
       if s_voynrsign ‘I’ and s_voynroption ‘BT’.
          n s_voynrhigh – s_voynrlow + 1.
          x_voynr s_voynrlow.

         do times.
            append x_voynr to itab_voynr.
            x_voynr x_voynr + 1.
         enddo.
      endif.
    endloop.

    loop at s_aotrf.
       if s_aotrfsign ‘I’ and s_aotrfoption ‘BT’.
          n s_aotrfhigh – s_aotrflow + 1.
          x_aotrf s_aotrflow.

         do times.
            append x_aotrf to itab_aotrf.
            x_aotrf x_aotrf + 1.
         enddo.
      endif.
    endloop.

    loop at itab_voynr assigning <fs_i_voynr>.
       read table itab_aotrf transporting no fields
             with table key voynr <fs_i_voynr>voynr.
       if sysubrc 0.
          message e023(z1with text028.
       endif.
    endloop.

However this is very slow plus I would need to code around the other possible alternatives such as “EQ”, “NB” if I wanted the user to have full flexibility.

Any ideas on this?

Scroll to Top