11.2 Creating Analytical Apps
In this section, we’ll show you how to create an analytical app using an example based on a sales order calculation view. The first step in this process is to create the SAP HANA Live view.
11.2.1 Create the SAP HANA Live View
For the SAP HANA Live view, you can either create it from scratch or create it by copying an existing view.
In this example, you’ll create a new view by copying an existing calculation view. Follow these steps:
- Log in to your SAP HANA system from SAP HANA Studio.
- Select the Developers perspective.
-
Create a new package by right-clicking either the Content folder or the existing package and selecting New • Package (see Figure 11.3).
Creating a Package
It isn’t necessary to create a new package in the same location that you created an old package (see Figure 11.3). The new package can be located anywhere in the Content folder. However, it’s important to keep in mind that the package you’re creating should be included in SAP Web Dispatcher. For example, in our demo system, sap.hba is included in SAP Web Dispatcher (refer to Chapter 3, Section 3.1.2).
Figure 11.3 Create New Package
- On the next screen, enter the package name, then click OK (see Figure 11.4).
- Right-click the new package and select New • Calculation View (see Figure 11.5).
- Enter a name for the view in the Name field, then select the Copy From checkbox. Click Browse (see Figure 11.6).
- Search for the word “salesorder”, then select SalesOrderQuery from the results. Click OK (see Figure 11.7).
-
Click Finish (see Figure 11.8).
Figure 11.7 Selecting Standard View
Figure 11.8 New Calculation View Parameters
- Right-click the new calculation view, then click Activate (see Figure 11.9).
-
After the calculation view is activated, preview the data by right-clicking the calculation view and selecting Data Preview (see Figure 11.10).
Figure 11.10 Previewing Data
-
Enter the parameters (i.e., for the client), then click OK (see Figure 11.11).
Figure 11.11 Enter Parameters
- You should now see the data under the Raw Data tab (see Figure 11.12).
We’ve successfully copied an existing calculation view and created a new one. In the next section, we’ll expose the calculation view by creating an OData service.
11.2.2 Create the OData Service
In the previous section, we created a calculation view, and now in this section, we’ll show you how to create an OData service and expose the calculation view as an OData service. Follow these steps:
- Log in to the SAP HANA system from SAP HANA Studio, then select the Project Explorer tab.
- Before you can start the OData service development, you must create a project, which you’ll use to group all your application-related artifacts. Next, you’ll create an SAP HANA XS project. Right-click in the blank area and select New • Project (see Figure 11.13).
- From the wizard, select SAP HANA • Application Development • XS Project, then click Next (see Figure 11.14).
-
Enter a Project name, then click Next (see Figure 11.15).
Figure 11.14 SAP HANA XS Project
Figure 11.15 SAP HANA XS Project Name
-
Now, we’ll add a workspace. You can skip this step and proceed to the next if you’ve already created a workspace. Otherwise, click Add Workspace (see Figure 11.16).
Figure 11.16 Adding Workspace
-
Select your SAP HANA system, then click Finish (see Figure 11.17).
Figure 11.17 Creating New Workspace
-
Select the workspace, then click Browse (see Figure 11.18).
Figure 11.18 Share Project Dialog Box
- Select the repository package you created in the first step and click OK (see Figure 11.19).
-
Uncheck the Add Project Folder as Subpackage checkbox and click Next (see Figure 11.20).
Figure 11.20 Unchecking Add Project Folder as Subpackage
-
Leave everything blank on this screen, and click Finish (see Figure 11.21).
Figure 11.21 Object Section
A new project is created with the calculation view. Make sure the application access file (XSACCESS) and the application descriptor files (XSAPP) are automatically created. Next, we’ll create the OData service file. Follow these steps:
-
Right-click the new project and select New • XSODATA File (see Figure 11.22).
Figure 11.22 New SAP HANA XS OData File
-
Enter the OData service File Name and click Finish (see Figure 11.23).
Figure 11.23 SAP HANA XS OData Service Parameters
-
Enter the code in for the new file you created (see Listing 11.1).
service
{
"sap.hba.nb/NBSALESORDERS.calculationview" as "NBSalesOrderQuery"
keys generate local "GenID"
aggregates always
parameters via entity "NBSalesOrderP"
;
}
annotations {
enable OData4SAP;
}Listing 11.1 OData Service
In the listing, sap.hba.nb is the location of the calculation view, and NBSALESORDER is the view you created. Your screen should look like the one shown in Figure 11.24 after you enter the code.Figure 11.24 OData Service File
- Click Save. Then, right-click the project and select Team • Commit (see Figure 11.25).
- Activate the project by right-clicking the project and selecting Team • Activate (see Figure 11.26).
Figure 11.25 Committing Changes
Figure 11.26 Activating Project
Next, let’s test the newly created OData service. Follow these steps:
-
Right-click the XSODATA service file and select Run As • XS Service (see Figure 11.27).
Figure 11.27 Running SAP HANA XS Service
-
After you log in, you should see something like what’s shown in Figure 11.28.
Figure 11.28 OData Service
- Now, append the URL with “$metadata” and press (Enter).
- You should see the metadata of the OData service you created (see Figure 11.29).
Figure 11.29 Metadata File
You’ve successfully created an OData service on the new calculation view. In the next section, we’ll configure the KPI.
11.2.3 Configure the KPI
In this section, we’ll show you how to create a KPI on the new calculation view and how to create a generic drilldown at a high level. In Chapter 6, Section 6.3, we covered the KPI creation process with step-by-step instructions. Refer to that chapter as needed to complete the following steps:
- Log in to SAP Fiori launchpad.
- Click the Create KPI app under the KPI Modeler group.
- On the next screen, you need to fill in the mandatory Title field and add a Description for the KPI (see Figure 11.30).
-
Scroll down to the next section and select the values by clicking
. Enter the information shown in Figure 11.31.
Figure 11.31 Data Source Parameters
Value Measure
If the Value Measure field list isn’t populated, the package in which your OData service is saved won’t be included in SAP Web Dispatcher. Therefore, be sure to include the package you created in Section 11.2.1 in SAP Web Dispatcher.
- After the fields have been entered, click Activate and Add Evaluation. Enter a unique Evaluation name as shown in Figure 11.32 on the Add Evaluation screen.
- Scroll down to the Input Parameters and Filters section to input parameters that are expected in the calculation view.
- Enter the SAP Client shown in Figure 11.33 in the Input Parameters section.
- Add the Target, Thresholds, and Trend values (see Figure 11.34):
- Click Activate and Configure Tile.
-
Select your evaluation and click Add Tile (see Figure 11.35).
Figure 11.35 Adding Tile
-
Enter the Tile Configuration details, then click Save and Configure Drill Down (see Figure 11.36).
Figure 11.36 Saving Tile
-
Return to the home screen by clicking
.
- From SAP Fiori launchpad, click the Configure KPI Drill-Down link.
-
Select the evaluation and click Configure (see Figure 11.37).
Figure 11.37 Configuring Drilldown
- Select the Customer from the dimensions list and click OK.
- Enter View ID and View Title, then click Save View (see Figure 11.38).
- Click Save Configuration.
You should now see the app in the catalog and be able to add the app from the catalog to your home group in SAP Fiori launchpad (see Figure 11.39).
You should now understand the end-to-end process of creating an analytical app. In the next section, we’ll look at the extension process for an analytical app.