A set is a way of organizing data by grouping related values together and giving them a name. Sets can be used to create hierarchies and they can contain one or more characteristics that are individual fields. Characteristics might represent an account number, cost center or business area.
Sets are easy to create and maintain and they give you more flexibility for maintenance because we dont need to add master data or table entries. Advantages of sets include:
- Sets are defined once and are not tied to specific applications.
- Can be used in multiple modules allowing them to be reused for different purposes such as reporting and allocation runs.
- New values added to a set are automatically stored in the system, no need to transport.
We can create a SET by using transaction GS01.
Several standard SAP FI/CO objects are stored technically as a SET for instance Cost Element Groups or Cost Center Groups.
The SET entries are stored in Table SETLEAF and contain one table item for each SET entry. It is possible to use single values or enter From To values as a range value.
If we want to work with SETS in ABAP programs we dont need to read the values out of Table SETLEAF we have to run function G_SET_GET_ID_FROM_NAME to get the setid first. When we received the setid we can run function G_SET_GET_ALL_VALUES to obtain the values of the SET into an internal table.
In this example we want to check if the account 449010 (char datatype) is within the SET FROM TO value of the cost element group SET. To do this we have to create a RANGE first and transfer the SET values to the Range. The special table type RANGES is useful for reading data in a flexible way. A Ranges table always has 4 fields:
- SIGN (‚I‘ = Include) or ‚E‘ = Exclude)
- OPTION (‚EQ‘ = Equal, ‚BT‘ = Between, etc.)
- LOW (from-value, of the type of the field to be typed)
- HIGH (to-value or empty, of the type of the field to be typed)
The IN command for RANGE tables can be used to check if a certain value is within a range of values.
We can use the debugger to run a test for an account that is out of range.