ABAP RESTful Application Programming Model, SAP BTP, SAP Odata Connector

ABAP RAP(RESTful Application Programming) Model

It is a set of concepts, tools, languages, and frameworks that help developers build innovative, cloud-ready, enterprise applications. RAP is based on REST architectural style, which is a simple and lightweight way of building web services.

Why RAP Model?

It offers an end-to-end development experience with Standardized architecture and development flow. It is an ABAP based model which uses frameworks such as Core Data Services (CDS) for defining semantically rich data models.

You will learn how to create a simple RAP model. In this example, we will create a table, CDS view entity, Metadata extension, Behavior definition, Service definition, Service Binding.

We will create below application for creation of Employee detail with the help of FIORI element.

Step1- Create package – ZTEST_NEWPR

Right click on the project –> New –> ABAP Package -> enter the name of package.

After that you can save this package in existing TR or if you want to create a new TR then you need to select radio button for create a new request, give description and finish.

Step2-Add Package in favorite packages- ZTEST_NEWPR

Right click on favorite package -> Add package -> name of the package ->finish.

Step-3 Create table – ZTEST_EMPTABLE

Right click on the package –> New –> Other ABAP Repository Object –> Select Database Table and enter the name of the table -> enter Description -> Next.

Below is the code snippet to create a table.

Step4 – Create class to pass data in table –ZTEST_EMPCLASS

Right click on package -> new -> ABAP class -> enter name of class -> description -> next.

This class is not a mandatory class. If you want to pass data in the table then you can create otherwise you can ignore this step.

Below is the code snippet to pass the data in table.

After executing this class, we will get the data in table.

Step5 – Create Root CDS Entity – ZTEST_EMP_DATADEF

Right click on the package –> New –> Other ABAP Repository Object –> Select Data Definition and enter the name of Root CDS Entity –> Select Define Root View Entity.

Below is the code snippet to create a CDS view.

Step-6 Create a Metadata Extension- ZTEST_EMP_METADATA

Right click on root view entity –> Select New Metadata Extension –> Enter the name of Metadata Extension.

Below is the code snippet to create a metadata extension.

Step7 – Create a Behavior Definition

Right click on root view entity –> Select New Behavior Definition.

All details will be already filled, just click next.

Below is code snippet for behavior definition.

Step8 – Create a Service Definition – ZTEST_EMP_SERVICE

Right click on root view entity –> Select New Service Definition

Below is the code snippet for service definition.

Step 9 – Create Service Binding

Right click on service definition –> Select New Service Binding. Here we need to choose Binding type OData V2-UI or OData V4-UI, for now we have chosen V2-UI.

Now publish the Service by clicking on Publish button.

After publishing, the service below screen will be display.

Test Application ->

Select Service and click on preview button.

To check the data, click on go button.

We can create a new record. Create button appearing in right corner.

After creating a new record.

If we want to update and delete record, we need to select that record and we can modify. Edit and delete button appearing in right corner.

If we want to get all the data in excel file or in PDF we can export as excel or PDF. Highlighted button is the export button.

Excel file after exporting.

PDF file after exporting.