CREATING AN ODATA SERVICE WITHIN THE BW4/HANA APPLICATION LAYER [Part I]

CREATING AN ODATA SERVICE WITHIN THE BW4/HANA APPLICATION LAYER [Part I]

Project background

In a recent project I did, the client wanted to expose a HANA calculation view to their B2B commerce cloud. The goal was to set up a REST-based API so the commerce cloud could access this view and generate a few graphs based on the customer that is signed in.

The solution was using ODP data extraction and an ODATA service exposing the HANA View.

It is possible to set this up from within the BW application layer.

Prerequisites

There are a few basic prerequisites that need to be fulfilled.

  • BW 7.4 or later
  • SAP Gateway Foundation must be installed

! Make sure your SAP license allows for this kind of data extraction.

Creating a new project

To create a new gateway service project, head over to the SAP Gateway Service Builder using T-code: SEGW

Here, we can create a new project by clicking the icon in the top left-hand corner. Give the project a name and choose the package where you want to develop the project. Make sure the project is of the type: Service with SAP Annotations.

 width=

Next, click the check box to create the project template. It should look something like this:

 width=

Define the model

Now that the project is set up, we can define our model that we want to expose to the API endpoint.

  1. To do this, right-click the  and select >

 width=

2. Follow the steps in the wizard:

  • Leave the RFC Destination as NONE
  • The ODP Context we want to use is . (other contexts such as ABAP Core Data Services, ADSO’s and BW data sources are also possible)
  • Search for the ODP Name using the search function or the explorer
  • Click the «Add ODP» button
  • If there are any related ODP’s you can add them as well.
  • Click Next

 width=

  • Add descriptions for the model name and service names
  • Remember these names for later use.
  • In the create object directory menu, you can assign the object to a package.

 width=

  • Select the fields you want to expose to the ODATA service (for demo purposes, I selected them all)

 width=

  • Click finish
  • Remember to save often

When the wizard has finished running, it will have added the view, and all the fields we have selected. Our design time objects are now created.

Blog by Bart Bryon