Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

range is subset

Former Member
0 Likes
820

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
701

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

5 REPLIES 5
Read only

Former Member
0 Likes
701

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.

Read only

Former Member
0 Likes
702

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

Read only

0 Likes
701

Hi,

Many thanks for your help.

Now everything works perfect.

Read only

Former Member
0 Likes
701

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

Read only

0 Likes
701

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.