‎2011 Sep 29 3:21 PM
Hi together,
how can I check if range A is subset of range B?
Or, how can I check if a sinlge combination of [ 'sign', 'option' 'low' 'high' ] is contained in a certain range B.
Please take into account that range B could contain option 'NE'.
Thanks for any help.
‎2011 Sep 29 3:37 PM
Hi,
Your A range can contain 'BT' with low and high values? In this case this can be quite complex since you will have to reconstruct the range to have all single values.... Otherwise something like:
LOOP AT A ASSIGNING <a>.
IF <a>-low IN B.
"->is a subset
ELSE.
"->is not a subset
ENDIF.
ENDLOOP.
should do the trick, but I guess you already thought about this...
If you have to handle 'BT', the difficult part would be to check e.g.:
A-sign = 'I'.
A-option = 'BT'.
A-low = '3'.
A-high = '5'.
that should be considered as a subset of:
B-sign = 'I'.
B-option = 'BT'.
B-low = '2'.
B-high = '6'.
But not if you add this line to range B:
B-sign = 'I'.
B-option = 'NE'.
B-low = '4'.
Kr,
m.
Edited by: Manu D'Haeyer on Sep 29, 2011 4:38 PM
‎2011 Sep 29 3:34 PM
Hi ,
Just use loop at range B where sign = rangeA-sign and option = rangeA-option and so on..
if SY-SUBRC = 0.
range A is subset of B
ENDIF.
ENDLOOP.
‎2011 Sep 29 3:37 PM
Hi,
Your A range can contain 'BT' with low and high values? In this case this can be quite complex since you will have to reconstruct the range to have all single values.... Otherwise something like:
LOOP AT A ASSIGNING <a>.
IF <a>-low IN B.
"->is a subset
ELSE.
"->is not a subset
ENDIF.
ENDLOOP.
should do the trick, but I guess you already thought about this...
If you have to handle 'BT', the difficult part would be to check e.g.:
A-sign = 'I'.
A-option = 'BT'.
A-low = '3'.
A-high = '5'.
that should be considered as a subset of:
B-sign = 'I'.
B-option = 'BT'.
B-low = '2'.
B-high = '6'.
But not if you add this line to range B:
B-sign = 'I'.
B-option = 'NE'.
B-low = '4'.
Kr,
m.
Edited by: Manu D'Haeyer on Sep 29, 2011 4:38 PM
‎2011 Sep 30 10:32 AM
‎2011 Sep 29 3:49 PM
It also depends on whether you are looking at theoretical or actual values. By theoretical, I mean that you are checking the complete range of possible values. Actual values would be objects (GLs or whatever) that actually exist.
In the second case, the best option would be to select the values based on both ranges and see if there are any overlaps.
Rob
‎2011 Sep 29 9:42 PM
To take what Rob said another step further... it's important to remember that ranges and select-options don't have much meaning outside the context of their data set. You will get different results when considering Positive Integers vs. All Integers vs. Real Numbers vs. Database Data. Depending on our requirement (what is the reason you want to know the intersection of the ranges) it might be easier to make a custom object rather than (mis)using the range data structure.