12

ABAP RAP(RESTful Application Programming) Model, Part- 1 –> Managed scenario

 2 years ago
source link: https://blogs.sap.com/2023/01/04/abap-raprestful-application-programming-model-part-1-managed-scenario/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
January 4, 2023 3 minute read

ABAP RAP(RESTful Application Programming) Model, Part- 1 –> Managed scenario

In this blog, 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 Driver detail with the help of FIORI element.

Image1-10.png

Step 1 –> Create table – ZRV_RAP_DRIVER

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

Image2-10.png

Here is the code snippet.

Image3-10.png

Step 2 –> Create Root CDS Entity ZI_RAP_DRIVER

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

Picture4-24.png

Here is the code snippet.

Picture5-19.png

Step 3 –> Create a Metadata Extension

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

Picture6-17.png

Here we annotate the CDS Entity and fields we add screen position, set selection field etc.

Here is the code snippet.

Picture7-17.png

Step 4 –> Create a Behavior Definition

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

All detail will be already filled, just click next.

Picture8-17.png

Here is the code snippet,

Note –> For managed scenario we don’t need a class. Create, Delete, Update functionality will work as a standard.

Picture9-13.png

Step 5 –> Create a Service Definition

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

Picture10-12.png

Here is the code snippet.

Picture11-13.png

Step 6 –> 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.

Picture12-12.png
Picture13-9.png

Now publish the Service by clicking on Publish button.

Picture14-10.png

Our RAP model is completed, now test the application.

Test Application –>

Select Service and click on preview button.

Picture15-7.png

Click on Go –> To see the data, if already available in system.

Picture16-8.png

Click on CREATE –> Here we can create new driver.

Picture17-8.png

UPDATE / DELETE –> To update or delete the record.

Select the entry from the list.

Picture18-6.png

These buttons appear on the top right corner.

Picture19-6.png

Conclusion –> After reading this blog you will be able to create simple RAP model application.

Give it a try and let me know in the comments if you need any help/support.

Please feel free to suggest if any correction is needed 🙂


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK