Introducing RESTful Application Programming
RAP is just one code line for all different deployment options, SAP S4HANA or the cloud scenarios. the core of the RAP is based on CDS and supports all the draft functionality, the extensibility, and out-of-the-box implementation to take all the technical implementation tasks.
With 7.5, it was the first time SAP introduced an end-to-end programming model. From CDS via BOPF up to the gateway level, we were able to create applications.
RAP is the successor of the ABAP Programming Model for SAP Fiori. SAP extended the core data services by the so-called behaviour definition. The extension of the CDS language, and also the extension of the ABAP language itself, are used in order to have the native concept of built-in business objects.
Define a Database Table
To implement the data model we would need at least one table. In this case, there is one single database table that contains flight connections. Here are the common steps that involve in the creation of a table.
To implement the data model we would need at least one table. In this case, there is one single database table that contains flight connections. Here are the common steps that involve in the creation of a table.
- Create a Table
- Defining Basic Table Attributes
- Adding Table Definition
- Creating the Data Element
- Defining the Primary Key
- Ensuring Concurrency Control
- Activating the Table
To create a database table, choose File -> New -> Other. A dialog box appears.
Once the above step is complete, It generates the database table template as below.
Generate ABAP Repository Objects
The generator is to generate the further objects that are required. These are CDS Entities, CDS Behaviour Definitions, CDS Metadata Extensions, a database table for the draft data, a Service Definition and a Service Binding. Once you have generated these objects, you will have a fully-functioning application, with create, read, update, and delete functions.
This wizard starts, and you must enter a package to which all the new objects will be assigned. You can then select the generator, for this example, we are using the ABAP RESTful Application Programming Model UI Service.
In this RAP model, you do not access the database table directly. Instead, you use a CDS data definition. In many ways, this is like an SQL view in the database. But CDS data definitions also contain important semantic information. At this stage of the generator, you enter the name of the definition.
With the view entity that we have created, you can read the data from the database. However, our app should also be able to create, modify, and delete data. To make this possible, you must define a behaviour definition. This is linked to the view entity and specifies which of the create, update, and delete actions are allowed. The behaviour definition can also contain the following kinds of definitions: Draft enabling, Numbering (Automatic number is enabled for the UUID field), Validations, Determination(performs calculation to fill fields in the data record). It declares which validations and determinations exist. However, they also need an ABAP implementation. The implementations are methods, so you, therefore, need an implementation class.
To expose the app, you need to create a service definition. This is an OData service, which you then expose using a service binding.
At the end of the wizard, the system displays a list of all the objects that it is going to generate.
Select the packaged and choose Finish.
Publish and Preview the Service
You must publish the service before you test the app. To, do so, open the service binding and choose Publish. Once you have done this, the entity you have created appears in the list of entities. Mark it and choose Preview to test the app.
Test the App
When you choose Preview, a browser window opens and you can create a new connection.
Comments
Post a Comment