Creating an OData V4 Service

Objective

After completing this lesson, you will be able to generate the RAP artifacts using the ABAP generator class, publish the service, and preview the application in the browser

ABAP RESTful Application Programming Model (RAP)

ABAP RESTful Application Programming Model (in short RAP) is the evolutionary successor of the ABAP Programming Model for SAP Fiori. RAP is a programming model for efficient development of SAP HANA-optimized OData services in SAP BTP ABAP Environment and SAP S/4HANA, on premise as well as in the cloud.

RAP consists of a set of concepts, tools, languages, and powerful frameworks that help developers to build innovative, cloud-ready SAP Fiori applications, local and Web APIs. Developers can easily extend SAP standard applications on the ABAP platform, in the cloud as well as on premise.

RAP provides a standardized development flow based on Core Data Services (CDS), the ABAP language, and business services in the modern, Eclipse-based ABAP Development Tools (ADT).

You can develop and model different types of services, local APIs, and business events using RAP.

CDS enables developers to work in the ABAP layer with ABAP Development Tools, while the code execution is pushed down to the database.

For RAP availability, check State-of-the-Art ABAP Development with the ABAP RESTful Application Programming Model (RAP).

RAP Development Artifacts

Watch the video to get an overview of the most important RAP artifacts.

Generate RAP Artifacts for Your Service Using the ABAP Generator Class

The focus of this course is on developing SAP Fiori elements apps, rather than the creation of an OData service. For this purpose, a generator was developed for the course that creates all the required RAP development artifacts for you. In this exercise, you will do the following:

  • Open ABAP perspective in Eclipse.
  • Execute the ABAP generator class ZDMO_CL_FE_TRAVEL_GENERATOR that will generate RAP development artifacts in a package with a unique ID.
  • Add the generated package to the favorite packages in the project explorer of the ABAP view.

Prerequisites

You have completed the exercise Set Up Development Environment in this unit (lesson: Getting Started).

Watch the Simulation and Perform the Steps

This exercise contains a simulation that takes you through detailed steps. You can find all the steps after the simulation. You can follow the simulation and perform the steps using your own trial account.

Steps

  1. Open ADT.

  2. Open the ABAP perspective in ADT.

    1. Select Window from the menu bar.

    2. Choose Perspective from the dropdown list.

    3. Choose Open Perspective from the subsequent list.

    4. Choose Other from the list of Open Perspective.

    5. Select ABAP from the Open Perspective dialog.

    6. Select Open from the bottom of the Open Perspective dialog. The ABAP perspective is opened. You can see the corresponding icon in the top right corner of the ADT.

  3. Open the ABAP generator class ZDMO_CL_FE_TRAVEL_GENERATOR.

    1. Select Open ABAP Development Object.

    2. Enter ZDMO_CL_FE_TRAVEL_GENERATOR as the search string name of the ABAP generator class in the Open ABAP Development Object dialog.

    3. Select OK from the bottom of the Open ABAP Development Object dialog. The zdmo_cl_fe_travel_generator class opens.

  4. Open the Console view.

    1. Select Window from the menu bar.

    2. Choose Show View from the dropdown list.

    3. Choose Other from the Show View option list.

    4. Expand the General menu from the subsequent Show View dialog.

    5. Choose Console from the expanded view.

    6. Select Open from the bottom of the Show View dialog. The Console view opens.

  5. Generate a package with a unique ID.

    1. Right-click Global Class tab of the ZDMO_CL_FE_TRAVEL_GENERATOR string.

    2. Choose Run As from the subsequent menu.

    3. Choose 1 ABAP Application (Console) F9 from the subsequent menu. After a minute or so, the package with a unique ID gets generated, and you can see the package name within the ABAP console.

    4. Use the keyboard copy option CTRL+C to copy the name of the generated package.

  6. Add the generated package to your Favorite Packages.

    1. Go to the Project Explorer tab.

    2. Expand the available folder. Note that this folder may differ for everyone.

    3. Right-click the Favorite Packages option.

    4. Select Add Package from the subsequent list.

    5. Paste the name of the generated package in the Select an ABAP Package dialog box.

    6. Select OK from the bottom of the Select an ABAP Package dialog box.

  7. View the generated RAP artifacts.

    1. Expand your Favorite Packages.

    2. Expand the ZFE_TRAVEL_###### package from the subsequent list of packages. Note that the package ID is unique for everyone.

    3. You can see the generated RAP artifacts.

  8. Open the CDS view for a travel entity.

    1. Expand Core Data Services from the generated RAP artifacts list.

    2. Expand Data Definitions.

    3. Double-click ZI_FE_TRAVEL_######.

Result

You successfully generated a package with a unique ID containing RAP artifacts. You have also added the package to the list of your Favorite Packages.

Publish the OData V4 Service

In this exercise, you will learn how you can publish your OData V4 service.

Prerequisites

You have completed the exercise Generate RAP Artifacts for your Service using the ABAP Generator Class in this lesson.

Watch the Simulation and Perform the Steps

This exercise contains a simulation that takes you through detailed steps. You can find all the steps after the simulation. You can follow the simulation and perform the steps using your own trial account.

Steps

  1. You have your generated package with the unique ID containing RAP artifacts open in ADT.

  2. Check the service definition that you generated using the ABAP generator class in the previous exercise.

    1. Find your Favorite Packages and expand Business Services within the ZFE_TRAVEL_######.

    2. Expand Service Definitions.

    3. Double-click ZFE_TRAVEL_###### to open the service definition.

  3. Open the service binding for your OData V4 service.

    1. Expand Service Bindings.

    2. Double-click ZUI_FE_TRAVEL_######_O4 from the expanded list.

  4. Select Publish to publish the service.

Result

You successfully published an OData V4 service. Once published, you can see the Service URL and the Entities and Associations exposed by the service.

Preview Your Service in ABAP Development Tools (ADT)

In this exercise, you will preview the service that you have already published in the previous exercise in a browser.

Prerequisites

You have completed the exercise Publish the OData V4 Service in this lesson.

Watch the Simulation and Perform the Steps

This exercise contains a simulation that takes you through detailed steps. You can find all the steps after the simulation. You can follow the simulation and perform the steps using your own trial account.

Steps

  1. You have the OData service package that you generated in a previous exercise opened in ADT.

  2. Ensure that the Service Binding: ZUI_FE_TRAVEL_######_O4 is displayed.

  3. Select Travel from the Entity Set and Association list of Service Version Details.

  4. Select Preview once Travel is highlighted. The preview of the service gets launched in your browser.

Result

You successfully viewed filter bar and a table. Note that you were not able to see any columns, as the corresponding annotations have not been added. You will add filter bar fields and table columns in the upcoming exercises.

Get an Overview of the Features That Will Be Implemented in the Training

Watch the Simulation

Here, you will explore the features that you will implement in this training.

Log in to track your progress & complete quizzes