Applying Best Practices for Modeling

Performing Practical Exercises

Objective

After completing this lesson, you will be able to performing practical exercises

Lesson 12.1 Implement External View for Value Help

Exercise Objectives

After completing this exercise, you will be able to:

  • Implement a Calculation View for use as Value Help in another Calculation View.

Business Example

You would like to provide a list of countries for a variable used to filter customers, but need to filter the list on the EMEA region only. For this purpose you will build an external calculation view to use as value help.

Note

The CUSTOMER table also contains a REGION column. However, this column does not contain regions such as AP, EMEA, NA, and so on, but instead the State (for US countries), or nothing (customers from Germany). So this column did not fulfill our requirement.

Overview of Exercise Tasks

  • Task 1: Create a Value Help Calculation View

  • Task 2: Consume the External Value Help View

Prerequisites

Prerequisites

Your SAP Business Application Studio development environment should have been set up and the HC300 project imported and deployed.

Task 1: Create a Value Help Calculation View

First, create the value help view that will provide the allowed countries. We will use a fixed restriction.

Steps

  1. If needed, launch SAP Business Application Studio and start your HCMOD development space.

  2. Create a calculation view using the data in the following table:

    FieldValue
    NameCVD_COUNTRIES_EMEA_VALUE_HELP
    LabelCountries in EMEA
    Data CategoryDIMENSION
    1. In the EXPLORER tree, choose HC300_A####→db→src and right-click the exercises folder. Choose New File.

    2. Enter CVD_COUNTRIES_EMEA_VALUE_HELP.hdbcalculationview as file name and press Enter.

    3. Enter the calculation view label and data category as specified in the table.

    4. Choose Create.

  3. Assign the table COUNTRIES of the TRAINING schema as the data source to the default projection node.

    1. Select the Projection node and choose + on the right of the node.

    2. In the Find Data Sources window, select the Search field and enter COUNTRIES.

    3. In the search result, select the table COUNTRIES (with synonym HC::COUNTRIES) and choose Finish.

  4. In the projection node, map all columns to the output.

    1. Double-click the Projection node to open the detailed setting pane.

    2. Select the Mapping tab.

    3. Under the Data Sources pane, right-click on the data source header HC::COUNTRIES and choose Add To Output.

  5. Define a filter expression to restrict countries to those in region EMEA.

    1. Select the Filter Expression tab, and under the section Components make sure the tab Elements is selected. Expand Columns and choose REGION.

    2. Enter =.

    3. Add a single quote (notice that a closing quote is automatically added).

    4. Between the single quotes, enter EMEA.

    The resulting expression should look exactly like this : "REGION"='EMEA'

  6. Deploy the calculation view.

    1. Choose the Deploy icon for the CVD_COUNTRIES_EMEA_VALUE_HELP calculation view.

    2. In the Console pane, check that the deployment completes successfully.

  7. Preview the calculation view raw data.

    1. Right-click your calculation view and select the Data Preview option.

    2. Switch to the Raw Data tab and you should see only countries of the EMEA region.

Task 2: Consume the External Value Help View

We will now create a calculation view that prompts the user to choose a country. However, the choices of countries will be restricted to those that are returned from the external value help view. In our case, those from EMEA region.

Steps

  1. Create a calculation view using the data in the following table:

    FieldValue
    NameCVD_CUSTOMERS_EMEA_VALUE_HELP
    LabelLocal Customers
    Data CategoryDIMENSION
    1. In the Explorer view, choose HC300_A####→db→src and right-click the exercises folder. Choose New File.

    2. Enter CVD_CUSTOMERS_EMEA_VALUE_HELP.hdbcalculationview as file name and press Enter.

    3. Enter the calculation view label and data category as specified in the table.

    4. Choose Create.

  2. Assign the table CUSTOMER from the TRAINING schema as the data source to the default projection node.

    1. Select the Projection node and choose + on the right of the node.

    2. In the Find Data Sources window, select the Search field and enter CUSTOMER.

    3. In the search result, select the table CUSTOMER (with synonym HC::CUSTOMER) and choose Finish.

  3. In the projection node, map all columns to the output.

    1. Double-click the Projection node to open the detailed setting pane.

    2. Select the Mapping tab.

    3. Under the Data Sources pane, right-click on the data source header HC::CUSTOMER and choose Add To Output.

  4. Define a variable to allow the user to select a country, but the countries that are presented for selection must be provided from the restricted results of the external value help view CVD_COUNTRIES_EMEA_VALUE_HELP.

    FieldValue
    NameVAR_COUNTRY
    LabelChoose Country
    View/Table Value HelpHC::CVD_COUNTRIES_EMEA_VALUE_HELP
    Reference ColumnHC::CVD_COUNTRIES_EMEA_VALUE_HELP.COUNTRY
    1. Select the Parameters tab.

    2. To view the drop-down list, choose +.

    3. Select Variable. Notice that a placeholder variable is created, called VAR_1.

    4. Select the variable VAR_1 to open the detailed settings and enter the settings provided in the table.

    5. Expand the section Apply Filter.

    6. Select the COUNTRY column.

    7. Choose Back.

  5. Deploy the calculation view.

    1. Choose the Deploy icon for the CVD_CUSTOMERS_EMEA_VALUE_HELP calculation view.

    2. In the Console pane, check that the deployment completes successfully.

  6. Preview the results to ensure that your value help for country only returns the countries in EMEA.

    1. In the Explorer view, right-click the CVD_CUSTOMERS_EMEA_VALUE_HELP calculation view and choose Data Preview..

    2. The value help should only show countries of EMEA.

    3. Choose a country (DE is a good choice as it has some data, whereas some countries do not).

    4. Choose Open Content.

    5. Select the Raw Data tab. You should see only customers in the country you have chosen.

  7. Close all the open tabs in Business Application Studio.

    1. Right-click any open tab and choose Close All.