Quantcast
Viewing all articles
Browse latest Browse all 9076

Re: how to deal with number

No. There is no built in set handling as you describe. The problem with the above posts is that they're concentrating on the implementation, rather than the actual solution, which should be flexible and reusable.

 

The best approach is to create a class. E.g. ZCL_SET that has methods to do what you want. Then you can write

 

Pre 7.4

 

DATA set_a TYPE REF TO zcl_set.

CREATE OBJECT set_a.

set_a->define_set_by_bounds( i_low = 2 i_high = 5 ).

 

DATA set_b TYPE REF TO zcl_set.

CREATE OBJECT set_b.

set_b->add_element( 3 ).

set_b->add_element( 5 ).

 

DATA set_diff TYPE REF TO zcl_set.

CREATE OBJECT set_diff.

set_diff = set_a->diff( set_b ).

 

7.4 up

 

DATA(set_a) = NEW zcl_set( ).

set_a->define_set_by_bounds( i_low = 2 i_high = 5 ).

 

DATA(set_b) = NEW zcl_set( ).

set_b->add_element( 3 ).

set_b->add_element( 5 ).

 

DATA(set_diff) = NEW zcl_set( ).

set_diff = set_a->diff( set_b ).

 

Now create the class ZCL_SET that implements define_set_by_bounds, add_element, diff

 

You could use internal tables as suggested by the other posters, or something of your own. You might want to start by defining a class to handle elements. Then you could have something that can handle sets containing elements of any kind.


Viewing all articles
Browse latest Browse all 9076

Trending Articles