Using @functions

Using the @Select Function

Objective

After completing this lesson, you will be able to apply the @Select function in SAP BusinessObjects Information Design Tool to build a dimension object dependent on the logic of another object.

@Select

The @Select function allows the use of the SQL expression from the SELECT clause of an existing object. You can use this function to define a new object based on the logic of another object.

This approach promotes code reuse and makes universe maintenance by keeping the main business logic in one source object.

The syntax of the @Select function is:

  • @Select(<Folder name>\<Object name>)
  • <Folder name>\<Object name> specifies the full path of another object in the business layer.

Business Example: Motors

Business users of the Motors universe request an object that displays a price range for car models. For each model, they want to show both the lowest and highest prices in one field, such as 10000 – 20000. The size of this range should be user-definable when they run a report.

To meet this requirement, you will build the final Price range object. Before creating this final object, you first need to create three intermediate objects:

  • Value
  • Start Price Range
  • End Price Range

Create the Value Parameter

First, you need to create a parameter that prompts the user to enter a value. This value defines the size of the price bracket, such as 1000, 50000, or 15000.

You create this parameter as follows:

  • Name: Value
  • Prompt to users: Enable this option.
  • Prompt text: Enter range value
  • Data type: Numeric
  • Allow multiple values: Disable this option.
  • Keep last values: Disable this option.
Parameter settings for Value allow users to enter a numeric range, with options for prompt text, default values, and multiple value selection.

Organize Your Intermediate Objects

For good practice and to ensure a clean user experience, place intermediate objects in a dedicated, hidden folder.

In your business layer, go to the Car folder. Create a new subfolder in the Car folder and name it Range.

Create the next two objects in the Range folder.

When you finish, set the Range folder’s visibility to hidden. This prevents report users from seeing the intermediate components, ensuring they only interact with the final Price range object

Folder named Range is set to hidden and contains Start Price Range and End Price Range, both enabled for result, filter, and sort.

Create the Start Price Range Object

This object calculates the lower boundary of the price range. It divides the model's price by the Value parameter, takes the integer part of the result, and then multiplying it back by the Value.

Create a new dimension object:

  • Name: Start Price Range
  • Data type: Numeric.
  • Select: FLOOR(Model.Model_Price / @Prompt(Value)) * @Prompt(Value)
Start Price Range dimension is configured with a numeric data type and an SQL SELECT formula using MODEL.MODEL_PRICE and a prompt value.

Note

The syntax used is that of the data source, which in our example is Sybase SQL Anywhere.

Create the End Price Range Object

This object calculates the upper boundary of the price range. Add the user-defined Value to the Start price range object you just created.

Create a new dimension object:

  • Name: End Price Range
  • Data type: Numeric.
  • Select: @Prompt(Value) + @Select(Car\Range\Start Price Rang)
The End Price Range dimension is configured with a numeric data type and a SQL SELECT statement combining a prompt value and the Start Price Range selection.

Create the Final Price Range Object

This is the object that users add to their reports. It combines the Start price range and End price range into a single, user-friendly text string.

A critical step here is to convert the numeric results of your intermediate objects into text (character strings) before combining them.

To convert the numbers to text and concatenate them with a dash, use the STR() function in the SELECT statement:

Create a new dimension object:

  • Name: Price Range
  • Data type: String.
  • Select: STR(@Select(Car\Range\Start Price Range))+' - '+STR(@Select(Car\Range\End Price Range))
Price range dimension is selected with a SQL definition combining start and end price range values for the Car entity.

It is important to understand that these objects are linked. When the Value parameter changes, all objects that depend on it will automatically update. This dynamic behavior is made possible by the @Select() function.

Test the Solution with SAP BusinessObjects Web Intelligence

When a user runs a report with the Price range object, they are be prompted to enter a value. If they enter 10000 and the model price is 22995, the report displays 20000 – 30000.

User selects Model, Model Price, and Price range as result objects, enters a price range value of 10,000, and views a filtered table of car models with prices and ranges.

Let's Summarize What You've Learned

  • Use the @Select function to define new objects based on the SQL logic of existing objects, ensuring that business logic is maintained in a single source.
  • Link intermediate objects, such as parameters and range boundaries, so that updates to the source logic or parameters automatically propagate to all dependent objects.
  • Combine multiple intermediate logic components into a single, user-friendly dimension while hiding background calculations to keep the reporting interface clean.