EDUCAÇÃO E TECNOLOGIA

Creating OData API based on a Mapped Data Source

This blog post will provide the steps to implement the pagination in OData by leveraging the CDS view and the SADL framework based on Mapped Data Source.

Introduction:

SADL offers a mapping editor in the SAP Gateway Service Builder to bind one or several SADL models to OData entity sets. This enables you to use SADL models as an additional data source besides RFC and others. Once the OData properties are mapped, the system provides a standard, optimized implementation of the OData service to retrieve the data.

Please refer the below link for the prerequisites and supported SAP version.

https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.52.4/en-US/820b24ce35c745bb9e0fb3a6e8d6dbd4.html

Now let see how to create the Gateway project using CDS view and SADL framework.

Agenda:

Creating CDS view

Create Gateway project

Test from Gateway client

1. Create the CDS view:

Create the CDS view from Eclipse

  • Right click on the package icon, and from the context menu select New->other ABAP repository object.

       

  • Enter the CDS view name and description as below:
  • Create the CDS view as below by selecting required fields from ACDOCA table.

2. Create Gateway project:

  • Now create the Gateway project from SEGW as below.
  • Once Gateway project is created, Right click on the Data Model and select ‘Import’ and DDIC Structure.
  • Enter the Entity Type Name and ABAP Structure and click on ‘Next’.
  • In the next screen, select the required parameters and click on ‘Next’
  • In the next pop up window, select the required key fields and click on ‘Finish’
  • As shown below, created the Gateway project with the entity type.
  • Next, in the service implementation, right click on the entity set and select the ‘Map to data source’.
  • Select F4 help on the Name field and enter the SADL model type as CDS Core Data Services and SADL model name as ZCDSV_ACDOCA_TEST. Select Enter.
  • The below screen will appear with the CDS view name. Select Enter.
  • Now map the SADL model elements to properties as shown below.
  • Once the mapping is completed, Press the Generate Runtime Objects /wp-content/uploads/2016/05/image018_964944.pngbutton.
  • Note: Using the Generate Runtime Objects button automatically saves the project.
  • Like below, the Runtime artifacts will be generated.
  • Expand the node Service Maintenance and right-click on GW_HUB and select Register
  • In the Add Service popup leave all values as defaulted and press the Local Object button to                assign the artifacts to the $tmp package. Then press Enter to continue.
  • Double-click on the GW_HUB entry under Service Maintenance. Verify that the registration               status on the right-hand side is showing a green traffic light.

3. Test from Gateway client:

  • Now select the ‘SAP Gateway client’ and execute the service with the $skip and $top parameters to implement the pagination.

Conclusion:

Creating OData service based on mapped data source using the CDS view with SADL framework, enable to optimized implementation of the OData service to retrieve the data along with pagination.