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_voynr–sign = ‘I’ and s_voynr–option = ‘BT’.
n = s_voynr–high – s_voynr–low + 1.
x_voynr = s_voynr–low.
do n times.
append x_voynr to itab_voynr.
x_voynr = x_voynr + 1.
enddo.
endif.
endloop.
loop at s_aotrf.
if s_aotrf–sign = ‘I’ and s_aotrf–option = ‘BT’.
n = s_aotrf–high – s_aotrf–low + 1.
x_aotrf = s_aotrf–low.
do n 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 sy–subrc = 0.
message e023(z1) with text–028.
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?