Skip to Content

Develop and Consume Queries on SAP Analytics Cloud

Requires Customer/Partner License
Develop analytical queries from ABAP system as data sources and consume them in the SAP Analytics Cloud to create analytical models, stories and multi-dimensional reports.
You will learn
  • How to create an analytical query as CDS View Entities
  • How to connect an ABAP System to SAP Analytics Cloud
  • How to consume analytical queries on SAP Analytics Cloud by creating models and stories
niloofar-flothkoetterNiloofar FlothkoetterNovember 23, 2021
Created by
niloofar-flothkoetter
February 5, 2021
Contributors
niloofar-flothkoetter

Prerequisites

Always replace #### with your initials or group number.

  • Step 1

    The new RAP based InA service exposure enables the SAP Business Technology Platform ABAP Environment developers to develop analytical queries(based on ABAP-CDS analytical data models) and expose them via the InA (Information Access) service protocol. In this Tutorial you will create a complete Analytical Data Model for Booking data. This consists out of dimensions for Carrier, Customer, Connection and Agency data, as well as an interface CDS view for Booking data which acts as a data source for the cube and query.
    These analytical queries can be further consumed in the SAP Analytics cloud to create analytical models, stories, multi-dimensional reports and more.

    overview
  • Step 2

    As a first task you will start to import templates that you will use in this tutorial to create Analytical CDS views such as dimension views, cubes and queries.

    The templates already contain certain annotations that are mandatory for the above mentioned analytical CDS views. If values such as the name of a property have to be added this can then simply be done by using code completion.

    1. Click on the following link to display the file analytical_templates.xml. Templates

    2. Right-click on the browser window and save the content as an xml-file called analytical_templates.xml.

      file
    3. Open ADT. In the menu choose Window > Preferences.

      window
    4. In the Templates dialogue choose Import.

      import
    5. Select the XML file analytical_templates.xml that you have saved.

      upload

      The Import-Dialog only allows to select files having the extension .xml. When you have downloaded the file using a different file extension you have first to rename your file so that it gets the extension .xml.

    6. You will see that three new templates have been imported that you will use in the following tutorial.

      Press Apply and Close

      apply
  • Step 3

    Dimensions views are links to various master data, which are later used in reporting as further attributes (according to which different aggregations can be made) and thus make up the versatility of our Analytical Model.

    In the following you will create four dimension views for Carrier, Customers, Connections and Travel Agencies so that you can visualize our measures Number of bookings and Flight price in relation to these dimensions.

    That means you will be able to create different charts that show how much money was spend for bookings for the connection Frankfurt–>New York compared to the connection Frankfurt–>Sydney or that show how much money was spend for flights with a certain airline.

    You will start to create a dimension view that contains the different Airlines / Carriers. Since our model will contain two measures, namely Number of bookings and Flight Price you will be able to answer questions such as

    • How much bookings are there per Carrier ? or
    • How much money was spend for bookings for a certain Airline?
    1. Open ADT and login to your ABAP System.
      If you do not have a package, create a new one.

    2. Right-click your package and choose New > Other ABAP Repository Object.

      new
    3. Choose Core Data Services > Data Definition and click Next.

      new data definition
    4. Enter the following values

      • Name:ZRAP500_I_CARRIER_###
      • Description: Dimension for Carrier
      • Referenced Object:/dmo/carrier

      and click Next.

      By selecting a table or another CDS view as Referenced object the wizard will use this object as a data source for the new CDS view and it will automatically add all fields into the DDL source code and it will also create camel Case aliases if needed.

      data definition
    5. Choose a transport request and click Next.

      Do NOT press Finish, because otherwise the wizard will not provide us the option to choose a specific template but would choose the template that you have used the last time.

      transport
    6. In the Templates dialogue choose the Define a View Entity for a Dimension and press Finish. The Define a View Entity for a Dimension template is one of the new data definition templates that you have imported in the last step. This template contains certain annotations which will be explained below that are mandatory for dimension views.

      define view
  • Step 4
    1. Now you need to edit the dimension view. Here you can use code completion to add the values for the annotations

      @ObjectModel.representativeKey

      and

      @ObjectModel.text.element

      that are needed for our dimension view.

      view
    2. Click on representativeKey, delete the placeholder representativKey so that you get an empty string ’’ , press CTRL + Space and choose CarrierId.

      key
    3. Click on textElement, delete the placeholder string textElement, press CTRL + Space and choose Name.

      text
    4. Save and activate the dimension.

      key
    5. Your final code should look like following:

      ZRAP500_I_Carrier_####
      Copy

      @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'Dimension for Carrier' @Metadata.ignorePropagatedAnnotations: true @Analytics.dataCategory: #DIMENSION @Analytics.internalName: #LOCAL @ObjectModel.representativeKey: 'CarrierId' define view entity ZRAP500_I_Carrier_#### as select from /dmo/carrier { @ObjectModel.text.element: ['Name'] key carrier_id as CarrierId, name as Name, currency_code as CurrencyCode }

      Coding explained

      Code Explanation
      @Metadata.ignorePropagatedAnnotations: true ignore annotations from tables and base views, because you want to completely control/override the annotations here.
      @Analytics.dataCategory you define this CDS view as a dimension.
      @Analytics.internalName: #LOCAL Create UUIDs.
      @ObjectModel.representativeKey: ‘CarrierId’ you define CarrierID as the representative key to be able to refer to it using @ObjectModel.foreignKey.association in the Cube that you will create later
      @ObjectModel.text.element: [‘Name’] Using this annotation you define that the attribute Name, contains the text element for a given CarrierId.
  • Step 5

    Customer Dimension

    The data for customers is contained in the table /dmo/customer. So you have to follow all steps above and create a dimension ZRAP500_I_Customer_#### and use the table /DMO/customer as a data source / reference object.
    The table /dmo/customer contains the columns first name and last name, but not the full name of the customer. You will hence add a new field to our CDS view where you calculate the full name so that you can use it as the text element for the key field CustomerId.
    The table /dmo/customer also contains fields that are too long to be used in analytics scenarios and it contains administrative fields that you do not want to show. You will hence delete these fields from the field list after having used the Define a View Entity for a Dimension template.

    1. Right click on your Core Data Services folder, choose Data Definition > New > Data Definition. Enter following values and press Next:

      • Name: ZRAP500_I_Customer_####
      • Description: Dimension for Customer
      • Referenced Object: /dmo/customer
      customer
    2. Select a transport request and press Next

    3. Select again the template Define a View Entity for Dimension and press Finish
    4. Add a new field CustomerName which will later be specified as the text element for the key field.

      concat_with_space(first_name, last_name, 1) as CustomerName,

    5. Remove or comment out these fields because they are too long for our analytics scenarios and you do not need any administration fields.

      //    email_address as EmailAddress,
      
      //    createdby as Createdby,
      
      //    createdat as Createdat,
      
      //    lastchangedby as Lastchangedby,
      
      //    lastchangedat as Lastchangedat
      
      
    6. Add the association _Country

      association [1] to I_Country as _Country on $projection.CountryCode = _Country.Country

      and add

      _Country

      to the field list so that it is exposed.

      Add new fields and an association
    7. Choose the property CustomerId for the annotation @ObjectModel.representativeKey and choose the newly created property CustomerName for the annotation @ObjectModel.text.element.

      Add text Element
    8. Save and activate the dimension.

      You expose the association _Country to be able to access country information in the cube and query.

    9. Your final code should look like following:

      ZRAP500_I_Customer_####
      Copy
        @AccessControl.authorizationCheck: #CHECK
        @EndUserText.label: 'Dimension for Customer'
        @Metadata.ignorePropagatedAnnotations: true
      
        @Analytics.dataCategory: #DIMENSION
        @Analytics.internalName: #LOCAL
        @ObjectModel.representativeKey: 'CustomerId'
      
        define view entity ZRAP500_I_Customer_####
          as select from /dmo/customer
          association [1] to I_Country as _Country on $projection.CountryCode = _Country.Country
        {
              @ObjectModel.text.element: ['CustomerName']
          key customer_id                                 as CustomerId,
              first_name                                  as FirstName,
              last_name                                   as LastName,
              concat_with_space(first_name, last_name, 1) as CustomerName,
              title                                       as Title,
              street                                      as Street,
              postal_code                                 as PostalCode,
              city                                        as City,
              country_code                                as CountryCode,
              phone_number                                as PhoneNumber,
              //    email_address as EmailAddress,
              //    createdby as Createdby,
              //    createdat as Createdat,
              //    lastchangedby as Lastchangedby,
              //    lastchangedat as Lastchangedat
              _Country
        }
      
      

    Connection Dimension

    The information about the connections (flights) is stored in the table /dmo/connection. In this dimension view you again add a new field. The newly created field Trip will show the departure airport and the destination airport in one string.
    For tables such as /dmo/connection that contain more than one key field, the key fields that are not annotated as the representative key field have to be annotated with a foreign key relationship.
    Since the key field ConnectionId will be annotated as the representativeKey you have to add an association that points to the Carrier dimension view which will be added as a foreign key relationship to the key field CarrierId.

    1. Right click on the folder Data Definitions > New > Data Definition.
    2. Enter the following values and press Next.
      • Name: ZRAP500_I_Connection_####
      • Description: Dimension for Connections
      • Referenced Object: /dmo/connection
    3. Select a transport request and press Next.

    4. Select again the template Define a View Entity for Dimension and press Finish.
    5. Add a new field Trip which will later be specified as the text element for the key field ConnectionId.

      concat(airport_from_id, concat(' -> ', airport_to_id)) as Trip,

    6. Add an association _Carrier

      
      association [1] to ZRAP500_I_Carrier_#### as _Carrier on $projection.CarrierId = _Carrier.CarrierId
      

      and expose it in the field list by adding _Carrier

    7. Add the following annotation to the key field CarrierId

      @ObjectModel.foreignKey.association: '_Carrier'

    8. Select the field ConnectionId for the annotation @ObjectModel.representativeKey

    9. Select the field Trip for the annotation @ObjectModel.text.element

    10. Save and activate the dimension view.

    11. Your final code should look like the following:

      ZRAP500_I_Connection_####
      Copy
        @AccessControl.authorizationCheck: #CHECK
        @EndUserText.label: 'Dimension for Connections'
        @Metadata.ignorePropagatedAnnotations: true
      
        @Analytics.dataCategory: #DIMENSION
        @Analytics.internalName: #LOCAL
        @ObjectModel.representativeKey: 'ConnectionId'
      
        define view entity ZRAP500_I_CONNECTION_#### as select from /dmo/connection
        association [1] to ZRAP500_I_Carrier_#### as _Carrier on $projection.CarrierId = _Carrier.CarrierId{
          @ObjectModel.text.element: ['Trip']
          @ObjectModel.foreignKey.association: '_Carrier'
          key carrier_id as CarrierId,
          key connection_id as ConnectionId,
          airport_from_id as AirportFromId,
          airport_to_id as AirportToId,
          concat(airport_from_id, concat('->', airport_to_id)) as Trip,
          departure_time as DepartureTime,
          arrival_time as ArrivalTime,
          distance as Distance,
          distance_unit as DistanceUnit,
          _Carrier
        }
      

    Agencies Dimension

    The information about the Agencies that perform the bookings is stored in the table /dmo/agencies.

    1. Right click on the folder Data Definitions > New > Data Definition.
    2. Enter the following values and press Next
      • Name: ZRAP500_I_Agency_####
      • Description: Dimension for Agencies
      • Referenced Object: /dmo/agency
    3. Select a transport request and press Next

    4. Select again the template Define a View Entity for Dimension and press Finish
    5. Remove these fields because they are too long for our analytics scenarios
      //   email_address as EmailAddress,
      
      //   web_address as WebAddress
      
      
    6. Choose the property Name for the annotation @ObjectModel.text.element.

       @ObjectModel.text.element: [‘Name’] 

    7. Choose the property AgencyId for the annotation @ObjectModel.representativeKey.

      @ObjectModel.representativeKey: 'AgencyId'

    8. Save and activate the dimension view.

    9. Your final code should look like the following:

      ZRAP500_I_Agency_####
      Copy
        @AccessControl.authorizationCheck: #CHECK
        @EndUserText.label: 'Dimension for Agency'
        @Metadata.ignorePropagatedAnnotations: true
      
        @Analytics.dataCategory: #DIMENSION
        @Analytics.internalName: #LOCAL
        @ObjectModel.representativeKey: 'AgencyId'
      
        define view entity ZRAP500_I_Agency_#### as select from /dmo/agency {
            @ObjectModel.text.element: ['Name']
            key agency_id as AgencyId,
            name as Name,
            street as Street,
            postal_code as PostalCode,
            city as City,
            country_code as CountryCode,
            phone_number as PhoneNumber
        //    ,
        //    email_address as EmailAddress,
        //    web_address as WebAddress
        }
      
  • Step 6

    You now have to create an interface view that serves as a data source for the Cube.

    1. Right click on the folder Data Definitions and choose New > New Data Definition from the context menu.

    2. Enter the following values and press Next

      • Name: ZRAP500_I_Booking_####
      • Description: Interface View for Booking
      • Referenced Object: /dmo/I_Booking_U
      interface
    3. Select a transport request and press Next.
      Do NOT press finish at this point because you need to select a different template in the next step.

    4. This time select the template Define a View Entity and then press Finish
      new interface
    5. Add an annotation @Semantics.amount.currencyCode to the property Flight Price that points to the property CurrencyCode.

       @Semantics.amount.currencyCode: ‘CurrencyCode’

    6. Add a new field AgencyId. The value for this field will be retrieved using the association _Travel.
      That points to the parent entity. This way the field AgencyId can be used as a dimension field.

       _Travel.AgencyID as AgencyID, 

      new field
    7. Save and activate the interface view.

    8. Your final code should look like the following:

      ZRAP500_I_Booking_####
      Copy
      @AbapCatalog.viewEnhancementCategory: [#NONE]
      @AccessControl.authorizationCheck: #CHECK
      @EndUserText.label: 'Interface View for Booking'
      @Metadata.ignorePropagatedAnnotations: true
      @ObjectModel.usageType:{
          serviceQuality: #X,
          sizeCategory: #S,
          dataClass: #MIXED
      }
      define view entity ZRAP500_I_Booking_#### as select from /DMO/I_Booking_U {
          key TravelID,
          key BookingID,
          BookingDate,
          CustomerID,
          AirlineID,
          ConnectionID,
          FlightDate,
          @Semantics.amount.currencyCode: 'CurrencyCode'
          FlightPrice,
          CurrencyCode,
          _Travel.AgencyID as AgencyID,
      /* Associations */
      _BookSupplement,
      _Carrier,
      _Connection,
      _Customer,
      _Travel
      
      }
      
  • Step 7

    The Cube is the analytical interface view that is ultimately used in the query and “holds together” the model. In addition to the facts and the measurable key figures (if necessary also calculations), it contains references to the dimensions.

    You will now use the Booking interface view as a data source to create a cube. All cubes must have at least one measure. The measurable data are the quantifiable fields that can be calculated, such as number of flight bookings and price of a flight. Using a query, you can SUM these fields. To create a cube, there is a mandatory header annotation:

    @Analytics.dataCategory: #CUBE 

    This annotation is part of the template Define a View Entity for a Cube that you have imported in your ADT installation at the beginning of this tutorial.

    1. Right click Data Definition and choose New > New Data Definition.

    2. Enter the following values and press Next

      • Name: ZRAP500_I_BookingCube_####
      • Description: Booking Cube
      • Referenced Object: ZRAP_I_BOOKING_#### (The booking interface view)
      new cube
    3. Choose a transport request and then choose Define a View Entity for a Cube and click Finish.

      template cube
    4. Add the following associations

      associations
      Copy
         association [0..1] to ZRAP500_I_Customer_####   as _Customer   on  $projection.CustomerID = _Customer.CustomerId
         association [0..1] to ZRAP500_I_Carrier_####    as _Carrier    on  $projection.AirlineID = _Carrier.CarrierId
         association [0..1] to ZRAP500_I_Connection_#### as _Connection on  $projection.AirlineID    = _Connection.CarrierId
                                                                        and $projection.ConnectionId = _Connection.ConnectionId
         association [0..1] to ZRAP500_I_AGENCY_####    as _Agency     on  $projection.AgencyID = _Agency.AgencyId
      

      you also need to add the following to entries to the field list

      
          _Agency,
          _Customer._Country    as _CustomerCountry
      
    5. In the created cube you define foreignKey associatons via _Customer, _Carrier, _Connection, and _Agency to be able to fetch and expose information in the cube and in the query.

      • Add the annotation @ObjectModel.foreignKey.association: '_Customer' to the field CustomerId
      • Add the annotation @ObjectModel.foreignKey.association: '_Carrier' to the field AirlineID
      • Add the annotation @ObjectModel.foreignKey.association: '_Connection' to the field ConnectionId
      • Add the annotation @ObjectModel.foreignKey.association: '_Agency' to the field AgencyID
    6. Comment out both lines of annotation @Semantics.amount.currencyCode and the property Flight Price.

    7. Add the following two fields alongside with a foreign key association

      foreignKey
      Copy
          @ObjectModel.foreignKey.association: '_CustomerCountry'
          _Customer.CountryCode as CustomerCountry,
          _Customer.City        as CustomerCity,
      
    8. You add fields that contain information about the customers

      customer
      Copy
          @ObjectModel.foreignKey.association: '_CustomerCountry'
          _Customer.CountryCode as CustomerCountry,
          _Customer.City        as CustomerCity,
          _Connection.Trip      as Trip,
      
    9. You now add Measures to our cube.

      You add a field TotalOfBookings

      totalOfBooking
      Copy
          @EndUserText.label: 'Total of Bookings'
          @Aggregation.default: #SUM
          1                     as TotalOfBookings,
      

      and the field Flight Price which is annotated as follows

      Flight Price
      Copy
          @Semantics.amount.currencyCode: 'CurrencyCode'
          @Aggregation.default: #MIN
          FlightPrice,
      
    10. Save and activate the cube.

      cube ADT
    11. Your final code should be look like following:

      ZRAP500_I_BookingCube_####
      Copy
      @AccessControl.authorizationCheck: #CHECK
      @EndUserText.label: 'Booking Cube'
      @Metadata.ignorePropagatedAnnotations: true
      
      @Analytics.dataCategory: #CUBE
      @Analytics.internalName: #LOCAL
      
      
      define view entity ZRAP500_I_BookingCube_####
        as select from ZRAP500_I_Booking_####
      
        association [0..1] to ZRAP500_I_Customer_####   as _Customer   on  $projection.CustomerID = _Customer.CustomerId  
        association [0..1] to ZRAP500_I_Carrier_####    as _Carrier    on  $projection.AirlineID = _Carrier.CarrierId
      
        association [0..1] to ZRAP500_I_Connection_#### as _Connection on  $projection.AirlineID    = _Connection.CarrierId
                                                                       and $projection.ConnectionId = _Connection.ConnectionId
      
        association [0..1] to ZRAP500_I_Agency_####     as _Agency     on  $projection.AgencyID = _Agency.AgencyId
      
      {
        key TravelID,
        key BookingID,
            BookingDate,
            @ObjectModel.foreignKey.association: '_Customer'
            CustomerID,
            @ObjectModel.foreignKey.association: '_Carrier'
            AirlineID,
            @ObjectModel.foreignKey.association: '_Connection'
            ConnectionID          as ConnectionId,
            FlightDate,
            //      @Semantics.amount.currencyCode: 'CurrencyCode'
            //      FlightPrice,
            CurrencyCode,
            @ObjectModel.foreignKey.association: '_Agency'
            AgencyID,
      
            @ObjectModel.foreignKey.association: '_CustomerCountry'
            _Customer.CountryCode as CustomerCountry,
            _Customer.City        as CustomerCity,
            _Connection.Trip      as Trip,
      
            /* Measures */
      
            @EndUserText.label: 'Total of Bookings'
            @Aggregation.default: #SUM
            1                     as TotalOfBookings,
      
            @Semantics.amount.currencyCode: 'CurrencyCode'
            @Aggregation.default: #SUM
            FlightPrice,
      
      
            /* Associations */
            _Carrier,
            _Connection,
            _Customer,
            _Travel,
            _Agency,
            _Customer._Country    as _CustomerCountry
      }
      
  • Step 8

    Since a query belongs to the projection layer (formerly known as consumption layer) it must have a C in its name according to the naming convention used in the Virtual Data Model (VDM) used in SAP S/4HANA. To create a query, there is a mandatory header annotation: @Analytics.query: true

    Again you can use a template that you have imported at the beginning of this tutorial.

    1. Right click Data Definition and choose New Data Definition.

    2. Enter the following values and press Next

      • Name: ZRAP500_C_BookingQuery_####
      • Description: Query for Booking
      • Referenced Object: ZRAP500_I_BookingCube_####
      new query
    3. Choose a transport request and then press Next.

    4. In the following dialogue choose Define a View Entity for Query and click Finish.

      template query
    5. Edit the code of your query and add the annotation @AnalyticsDetails.query.axis to all properties except the two measures FlightPrice and TotalOfBookings. All fields beside the field CustomerCountry get the annotation @AnalyticsDetails.query.axis: #ROWS, whereas the field CustomerCountry gets the annotation @AnalyticsDetails.query.axis: #COLUMN.

    6. You add a currency conversion to the field FlightPrice to be able to comparison all flight prices in a single currency.

      ```
            @Semantics.amount.currencyCode: 'CurrencyCode'
            currency_conversion (
            amount => FlightPrice,
            source_currency => CurrencyCode,
            target_currency => cast( 'EUR' as abap.cuky( 5 ) ) ,
            exchange_rate_date => cast ('20200101' as abap.dats),
            exchange_rate_type => 'M'
            ) as FlightPrice
      ```
      
    7. Save and activate the query.

      ADTquery

      Using the template the mandatory annotations for query is set automatically.
      @Analytics.query: true
      With the annotation @AnalyticsDetails.query.axis: , the elements of the view can be positioned on multiple axes: Rows, Columns and Free. The elements can be directly annotated with their axis. All measures (elements which can be aggregated) need to be on the same axis. The annotation of the first measure will therefore be used for all measures of the query. If @AnalyticsDetails.query.axis: is not found, the system positions the measures on the columns.

    8. Your final code should look like the following:

      ZRAP500_C_BOOKINGQUERY_####
      Copy
      @AccessControl.authorizationCheck: #CHECK
      @EndUserText.label: 'Query for Booking'
      
      
      @Analytics.query: true
      
      
      define view entity ZRAP500_C_BOOKINGQUERY_#### as select from ZRAP500_I_BookingCube_#### {
      @AnalyticsDetails.query.axis: #ROWS
      key TravelID,
      @AnalyticsDetails.query.axis: #ROWS
      key BookingID,
      @AnalyticsDetails.query.axis: #ROWS
      BookingDate,
      @AnalyticsDetails.query.axis: #ROWS
      CustomerID,
      @AnalyticsDetails.query.axis: #ROWS
      AirlineID,
      @AnalyticsDetails.query.axis: #ROWS
      ConnectionId,
      @AnalyticsDetails.query.axis: #ROWS
      FlightDate,
      @AnalyticsDetails.query.axis: #ROWS
      CurrencyCode,
      @AnalyticsDetails.query.axis: #ROWS
      AgencyID,
      @AnalyticsDetails.query.axis: #COLUMNS
      CustomerCountry,
      @AnalyticsDetails.query.axis: #ROWS
      CustomerCity,
      @AnalyticsDetails.query.axis: #ROWS
      Trip,
      
      
        TotalOfBookings,
        @Semantics.amount.currencyCode: 'CurrencyCode'
        currency_conversion (
        amount => FlightPrice,
        source_currency => CurrencyCode,
        target_currency => cast( 'EUR' as abap.cuky( 5 ) ) ,
        exchange_rate_date => cast ('20200101' as abap.dats),
        exchange_rate_type => 'M'
        ) as FlightPrice    
      
      }
      
  • Step 9

    Similar to the SAP Fiori Elements preview which is offered for OData V2 UI and OData V4 UI service bindings there is now an Analytical Data Preview available. This can be used by the ABAP developer to test the implementation of an Analytical Query since the preview uses the InA protocol.

    Now that you have created the query it is possible to use a data preview to test our implementation.

    1. Navigate to the folder Data Definition
    2. Right click on the query ZRAP500_C_BOOKINGQUERY_#### and select Open with > Data Preview
    Right Click
    1. A new browser tab will open and you might have to authenticate using the credentials of your SAP BTP ABAP environment system.
    Authenticate
    1. You can see the data that has been retrieved using the InA-Protocol. Please note that the measures are grouped by the Country/Region Key.
    Data Preview
  • Step 10

    You use a service definition to define which data is to be exposed as a business service, using one or more business service bindings.

    1. Right-click your created query in step 6 and choose New Service Definition.

      new service definition
    2. Enter the following values and press Next.

      • Name: ZRAP500_UI_BOOKING_####
      • Description: Booking query service definition
      • check if Exposed Entity is your created query ZRAP500_C_BOOKINGQUERY_####
      service definition
    3. Select transport request and press Next.

    4. Select the template Define Service and press Finish.
    5. After the query is exposed as a service it must be activated by pressing Ctrl+F3
  • Step 11

    The service binding is used to bind a service definition to a communication protocol and in our case, the protocol that enables web-based data access from ABAP systems is the Information Access (InA) protocol.

    1. Right click your newly created service definition and choose New Service Binding.

      RightClick
    2. Enter the following values and press Next

      • Name: ZRAP500_UI_BOOKING_####
      • Description: Booking Query Service Binding
      • Choose InA - UI as Binding Type
      • Check that in the field Service Definition the service definition ZRAP500_UI_BOOKING_#### is listed that you have created service definition in last step
      new binding
    3. Choose a transport request and click Finish.

    4. Activate your service binding.
    5. After activation, the external service name for your query is displayed.
      service binding

      The analytical query will be displayed with the external service name in SAP Analytics Cloud as the data source.

  • Step 12
    1. Right-click your package, choose New > Other ABAP Repository Object.

      New
    2. Search for IAM App under Cloud Identity and Access Management. Click Next.

      New
    3. Enter the following values and press Next

      • Name: ZRAP500_BOOKING_####
      • Description: IAM App for Booking Query
      • choose EXT-External App as Application Type
      new IAM APP
    4. Choose a transport request and click Finish.
      Your created IAM App name will get an EXT automatically in his name like: RAP500_BOOKING_####_EXT.

      IAM App
    5. Go to the Services tab and click on insert button.

      Add
    6. Select Service Type as InA - UIand your Service Name which is your service binding name ZRAP500_UI_BOOKING_####. Click OK.

      Find service
    7. Save and Publish Locally.

      publish locally
  • Step 13
    1. Right-click Cloud Identity and Access Management in your package, choose New > Business Catalog.

      business catalog
    2. Enter a Name and Description and click Next.

      next
    3. Choose a transport request and click Finish.

    4. To create a Business Catalog App Assignment, in your created Business Catalog click Apps, click Add, assign your previously created external IAM app as IAM App. Enter a Name and Description and click Next.

      IAM App
      IAM App
    5. Choose a transport request and click Finish. The Business Catalog App Assignment will be opened.

    6. Back to the Business Catalog, choose your Assignment ID and click Publish Locally.

      publish
  • Step 14
    1. Login to the Fiori launchpad and open Maintain Business Roles App under Identity and Access Management.

      maintain business roles
    2. Navigate to the SAP_BR_Developer Role, select Assign Business Catalogs and click Edit.

      Assign Business Catalogs
      Add Business Catalog
    3. Click Add and find your business catalog in the popup and click OK to add the business catalog.

      Add
      select
    4. Check in the Assigned Business Catalogs, if your business catalog is added in the list. Click Save.

      save
  • Step 15
    1. Back to the main page of Fiori launchpad and open Communication Systems App under Communication Management.

      Communication Systems
    2. Click New to create a new communication system. Enter System ID and System Name, click Create.

      new communication system
      edit communication system
    3. The new communication system will be opened. Switch Destination Service to OFF and now enter you SAP Analytics Cloud host name (ex: ###.cloud.sap) as Host Name and 443 as Port. Click Save.

      edit communication system
    4. Back to the Communication Management and open Communication Arrangements to create a new one.

      communication arrangement
    5. Click New and select SAP_COM_0065 as Scenario.Enter a name for your communication arrangement and click Create.

      create
    6. The new communication arrangement will be opened. Choose the communication system which you created previously in the Communication System field. Provide the Tenant ID of your SAP Analytics Cloud tenant.

      tenant

      Tenant ID can be found under the main menu of the SAP Analytics Cloud tenant, click System > About > System Name.

    7. Under the Outbound Services, the service status for UI Link Navigation should be checked as Active and Retrieve Stories should be unchecked, click Save.

      Outbound
  • Step 16
    1. Login to the SAP Analytics Cloud tenant.

      Login
    2. Open the main menu and click Connection and on the Connection Window click Add. In the popup under Connect to Live Data click SAP S/4 HANA.

      add connection
      connection
    3. In the New S/4 HANA Live Connection dialog enter Name and Description, Connection Type has to be Direct, for Host copy your Fiori launchpad link like ###.abap-web.stagingaws.hanavlab.ondemand.com. Enter 443 in HTTPS Port field, and 100 for Client. As Authentication Method choose SAML Single Sign-on (Standard Compliant). Click OK.

      new connection
    4. check the result.

      result
  • Step 17

    Models transform your raw data into useful information that can then be used to create dynamic visualizations. Since you will use the unique feature Live Data Connection SAP Analytics cloud will create the model based on the analytical query that you have created and published in the previous exercise. Based on such a model you can perform online analysis without the need of data replication.

    1. Expand navigation bar.

      navigation bar
    2. Choose Modeler and click Live Data Model

      live data
    3. In the popup choose SAP BW for System Type

      system type
    4. Choose your created connection in the last step as Connection and login with your username and password in the second popup.

      connection
    5. Select your created Query in the last exercise as Data Source.

      data source
    6. Click OK to continue.

      ok button
    7. In the model you can check all Dimensions and Measures.

      measures
      dimensions
    8. Save the new model and enter the following values and click OK:

      • Name: ZRAP500_####
      • Description: Model ####
      save
    9. Check your model in the Modeler page.

      modeler
  • Step 18

    A story is a presentation-style document that uses various elements such as charts, images or tables to visualize your data.
    Adding a chart starts with picking a chart type. Then you select your model and add measures and dimension and start on working how the data is displayed. Here you will create a story including a chart, a table and a Donut chart.

    Open a blank dashboard

    1. Expand navigation bar and click Stories.

      stories
    2. Choose Dashboard as your template.

      template
    3. A Blank Dashboard will be opened.

      blank
    4. Enter a Dashboard Title like RAP500_####.

    Now you can insert some charts or tables and use the model you created before based on your analytical query.

    Insert Chart

    1. To insert a chart, click on the chart icon in the task menu and select your model with double clicking your model.

      insert chart
    2. You can move the chart with click and drag around the page.

      move chart
    3. After you found a place for your chart, you need to add some measures and dimensions, which should be shown on the chart. You will find all settings on the right hand side under Builder.

      Builder
    4. Open + Add Measure and choose Flight Price. You will see the sum of all flight prices that have been booked on the chart.

      measure
    5. Open + Add Dimension and choose Country/Region Key. Now there is a chart which shows how the flight costs are distributed in different countries your customers live in.

      dimension

    Insert Table

    1. To insert a table, click on the table icon. A Table will be created and all dimensions and measures will be displayed. You can move the table, make it bigger. You can change dimensions and measures under Builder.
    table

    In the table you can find all data from your query, what you choose as ROWS or COLUMNS. You have just one dimension CustomerCountry in columns and all other dimensions are in rows.

    columns

    Insert Donut Chart

    1. Insert another chart and choose Donut under Builder > Chart Structure.

      donut
    2. Choose Flight Price under + Add Measure and choose Airline ID under + Add Dimension.

      You now have a visualization how the booking costs are distributed in different airlines.

      measure
      chart donut

    Save the Story

    1. You are almost done with your story, you need just to save the story. Click on save icon and choose Save.

      save
    2. Enter following values and click OK

      • Name: RAP500_####_Story
      • Description: Story ###
      story
    3. You will find your new created story under Welcome to Stories

    welcome

    You have used the preconfigured connection of the SAP Analytics Cloud instance to connect to the SAP BTP ABAP environment system where you have developed an Analytical Query. The data was retrieved using a Live Data Connection so that any change in the data was immediately reflected in the visualization of your query in SAP Analytics Cloud.

  • Step 19

    You can create more different and complicated analytics charts and tables with your query. Here there is some more examples.

    1. Click the chart icon in the task menu, click Correlation and choose Scatter plot.

      correlation
    2. Choose Flight Price and Total of Booking as X and Y axis and Customer ID as dimension. You can choose Country/Region Key as Color dimension to have different colors for each country in this chart, you can make the chart bigger or move it around your dashboard too.

      chart
    3. Click again chart icon in the task menu, click Distribution and choose Tree Map.

      Distribution
    4. Choose Total of Booking as Size under Measures, TRIP as Label under Dimensions. You can change the title of the chart with double clicking the title or choose an other color for this chart.

      trip
    5. Do not forget to save your story.

      save
  • Step 20

    Where can you create a model or story?

Back to top