Show TOC

Background documentationValue Range Expression

 

You use value range expressions to check if the value of a test parameter lies within a certain range. The result of a value range expression is always of type boolean. The expression returns the value as true or false depending on whether the value falls within the defined range.

Structure

Static vs. Dynamic Range Boundaries

Defining fixed boundaries for a range comparison at design time is a good starting point and easy to be done. At runtime, the system compares the values passed to the expression context with the values defined for the range and returns the appropriate result. However, in certain use cases it may be necessary to evaluate the range boundaries dynamically, as the following scenario illustrates.

Example Example

For an insurance company, you want to classify the tobacco consumption of a customer. You may define the following value range expressions for this:

  • Cigarettes per day = 0

  • Cigarettes per day between [1..10]

  • Cigarettes per day between [11..20]

  • Cigarettes per day between [21..50]

  • Cigarettes per day greater than [50]

The ranges listed above are ready for insertion into the rows of a decision table where you can assign a classification result to each degree of tobacco consumption.

However, in the course of time it may turn out that the assumed threshold (> 50) for the highest risk class seems to be unreliable and must be adapted by taking additional factors into account that influence the risk of physical affection. You can then decide to redesign the first approach as follows:

For the fourth and fifth of the ranges defined above, replace the static boundary value of 50 by a reference to a formula expression that dynamically calculates a more reliable value by considering additional influencing factors. For example, smoking 50 cigarettes per day may have different effects depending on a person's age or whether a person lives in the mountains or in an industrial town, and so on.

With this modification, the threshold between the highest and the second-highest risk class turns from a static value into a dynamic value, which is more adequate to properly reflect real-world conditions.

End of the example.
Explicit vs. Implicit Ranges

In BRFplus, ranges can be maintained either explicitly by defining a value range expression that can be reused by other objects, or implicitly by defining the range condition directly inside of a superordinate object where the range is needed. Implicit ranges are often used, for example, to test the context data passed to a decision table expression.

The decision whether you use explicit or implicit ranges is based on the need for reusability:

  • If certain value comparisons exist that are typical for your use cases and important for the flow control of your business processes (for example, clustering of ages, income, product groups, countries, and so on), and if these comparisons are needed at many different places in your application, you use explicit, reusable value range expressions.

  • If the comparisons that you want to model are mostly created in an ad-hoc manner and are rarely recurring elsewhere in your scenarios, it may be more convenient to use implicit ranges, thus accepting the loss of reusability.

Constraints

Although theoretically, you can define value range expressions consisting of a virtually infinite number of range comparisons combined in one expression, there are practical limits to the complexity that the system can handle. This is true regardless of whether you use explicit or implicit ranges. The following constraints apply:

  • Backend

    In the backend, the system can handle value range expressions that consist of several thousands of comparisons. However, the higher the complexity, the higher the system workload when it comes to code generation. Under extreme circumstances, it could even happen that the generated class methods would exceed the maximum code size limit that can be handled by the ABAP code engine. Therefore, we recommend to limit the maximum value range complexity to approximately 1000 comparisons per value range expression.

  • Frontend

    Rendering complex value range definitions using ABAP Web Dynpro technology imposes high workload on the system, especially in terms of high memory consumption. System overload can already occur at a degree of complexity that is significantly lower compared to the processing capacity of the backend. Therefore, displaying value range definitions in the UI is limited to a maximum of 99 comparisons per value range expression.

    Note Note

    If you need to define value range expressions with 100 value comparisons or more, you can only accomplish this programmatically. Due to the frontend limitation, there is no way of interactively defining value ranges with that degree of complexity in the BRFplus workbench.

    End of the note.

Example

In the tariff table for a courier company shown below, the rates are calculated based on the region and weight of the consignment. In the table, each cell in the weight column can be represented as value range expressions. The cell values become the value range parameters and the column becomes the test parameter. Each cell in the weight column returns a boolean value depending on the input and the condition described in the table.

Region

Weight

Tariff

Asia-Pacific

Less than 10 kg

$40

Asia-Pacific

Between 10 kg and 50 kg

$55

Asia-Pacific

Above 50 kg

$70

Europe

Less than 10 kg

$30

Europe

Between 10 kg and 50 kg

$45

Europe

Above 50 kg

$60