Skip to Content

Expose a Standard Core Data Service for ABAP Environment

test
0 %
Expose a Standard Core Data Service for ABAP Environment
Details
// Explore More Tutorials

Expose a Standard Core Data Service for ABAP Environment

10/15/2018

Create a service definition, service binding and communication scenario to expose a Core Data Services (CDS) view in SAP Cloud Platform ABAP Environment.

You will learn

  • How to create a service definition
  • How to create a service binding
  • How to create a communication scenario

In this tutorial, wherever XXX appears, use a number (e.g. 000).

Create all business services with ABAP namespace Z....


Step 1: Overview

You need to create an OData service by defining and binding a service based on the corresponding CDS view. As soon as the OData service is published in the local system repository, it is ready to be consumption using an OData client, such as a SAP Fiori app. To be able to use this exposed service and related service binding, you need to create a published Communication Scenario. This published Communication Scenario will be assigned in to a Communication Arrangement.

Create ABAP package
Log on to answer question
Step 2: Create your own ABAP package

Mark the steps 1 as completed by pressing Done if you have already created the package Z_Package_XXX (where XXX is your group number) in the previous tutorials.

  1. Open Eclipse and connect to your system.

  2. Right click on main package ZLOCAL choose New > ABAP Package.

  3. Create your own ABAP development package Z_PACKAGE_XXX as a sub package of ZLOCAL.

    • Name: Z_PACKAGE_XXX
    • Description: my new package
  4. Click Next.

    Create ABAP package

  5. Select package properties and click Next.

    • Software Component: ZLOCAL
    Create ABAP package
  6. Select a transport request and click Finish.

    Transport request

Add your package to Favorite Packages.

Log on to answer question
Step 3: Create a service definition

We want to create service definition to expose CDS entities and their behavior.

  1. Right click on your package and choose New > Other ABAP Repository Object > Business Services > Service Definition.

  2. Click Next.

    Add Service Definition

  3. Create a service definition by adding following information.

    • Name: Z_DEF_XXX
    • Description: service definition
  4. Click Next.

    Create Service Definition

The Service definition is now created.

Created Service Definition
Log on to answer question
Step 4: Expose CDS View

Exposition of the CDS view I_Currency and provide Currency as alias.
Do not forget to save and activate!

@EndUserText.label: 'Demo service Definition'
define service Z_DEF_XXX {
  expose I_Currency as Currency;
}
Log on to answer question
Step 5: Create a service binding

We want to create service binding to bind service to a protocol and preview.

  1. Right click on your package and choose New > Other ABAP Repository Object > Business Services > Service Binding.

  2. Click Next.

    Add Service Binding

  3. Enter data for a new service binding. Use the service definition created in last step.

    • Name: Z_BIND_XXX
    • Description: service binding
  4. Click Next.

    Create Service Binding

Log on to answer question
Step 6: Publish your service binding

Click Publish locally, and then you will see the service name and service URL in the table.

Publish Service Binding
Log on to answer question
Step 7: Preview your service binding

After publishing the business service, you can preview the published business service as SAP Fiori Elements app in the Service Binding editor:

  1. Go to the Service Details on the right side

  2. Either double-clicking on the entity Currency or right-clicking on it and then selecting Open preview for Fiori Elements App.

    Preview Service Binding

  3. Login with your username and password.

    Login

  4. To set some filters click on settings icon.

    set Settings

  5. Select fields that shall be displayed or select all and click OK.

    select fields

  6. Click on GO.

    GO button

  7. You can see the filtered data on UI.

    UI view

Log on to answer question
Step 8: Create a communication scenario
  1. Right click on your package and choose New > Other ABAP Repository Object > Communication Management > Communication Scenario.

  2. Click Next.

    Add Communication Scenario

  3. Enter data for a communication scenario.

    • Name: Z_COMMU_XXX
    • Description: communication scenario
  4. Click Next.

    Create Communication Scenario

Log on to answer question
Step 9: Add inbound into communication scenario
  1. Open the created communication scenario and navigate to Inbound tab.

  2. Check Basic under Supported Authentication Methods.

  3. Click Add inbound service.

  4. Browse the service binding created before, Z_BIND_XXX, and select inbound service ID Z_BIND_XXX_IWSG instead (where XXX is your group number) .

    Add Inbound

    Add Inbound

Log on to answer question
Step 10: Publish communication scenario

Navigate to the Overview tab and publish the scenario locally.

publish
Log on to answer question
Step 11: Test yourself

Define a service definition with following information:

  - annotation: `@EndUserText.label`: `Test`
  - service name: `service Z_Testyourself `
  - expose `I_Currency` as Currency
×

Next Steps

Back to top