In this post, you will learn about using the ‘Generate ABAP Repository Objects’ feature of Eclipse ADT to create RAP Service based on a custom table.

If you are not familiar with RAP, read the introduction below proceeding. ABAP RESTful Application Programming Model [1] – Introduction

Using RAP Generator

Create a table similar to /dmo/travel. Note that the fields are similar but all fields are included in the table definition directly and there are fields for etag and locking mechanism ( last_changed_at and local_last_changed_at )

@EndUserText.label : 'Dummy Travel Table'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zjp_gen_travel_1 {

  key client            : abap.clnt not null;
  key travel_id         : /dmo/travel_id not null;
  agency_id             : /dmo/agency_id;
  customer_id           : /dmo/customer_id;
  begin_date            : /dmo/begin_date;
  end_date              : /dmo/end_date;
  @Semantics.amount.currencyCode : 'zjp_gen_travel_1.currency_code'
  booking_fee           : /dmo/booking_fee;
  @Semantics.amount.currencyCode : 'zjp_gen_travel_1.currency_code'
  total_price           : /dmo/total_price;
  currency_code         : /dmo/currency_code;
  description           : /dmo/description;
  overall_status        : /dmo/overall_status;
  attachment            : /dmo/attachment;
  mime_type             : /dmo/mime_type;
  file_name             : /dmo/filename;
  created_by            : abp_creation_user;
  created_at            : abp_creation_tstmpl;
  last_changed_by       : abp_locinst_lastchange_user;
  last_changed_at       : abp_locinst_lastchange_tstmpl;
  local_last_changed_at : abp_lastchange_tstmpl;

}

Activate the table.

Right-click on the table and choose to Generate ABAP Repository Objects.

Enter Description and select ‘ABAP RESTful Application Programming Model:UI Service’ in the Generator drop-down. Click Next.

Provide names for each of the objects.

Data Model

Behavior

Service Projection

Service Definition

Service Binding

This is the last object. After providing the details click Next.

All the object names for the objects to be generated will be shown. Click Next.

Choose a TR and click on Finish.

The generation will start.

Post generation, the below screen with Service Binding will appear where you only need to Publish the Service.

Once the service is published, it can be tested by selecting the entity and clicking on Preview.

Click on Go to see the data or Create new data.

Right-click on the Package and choose Refresh to refresh the tree node and see all the generated artifacts,

All the generated objects are visible.

These objects can be used as a reference to understand the model in more details.

The generated service can be easily enhanced to add more features and can also be used to create a Fiori Element Application.

Visit ABAP RESTful Application Programming Model to explore all articles on ABAP RAP Model.


If you like the content, please subscribe…

Join 4,032 other subscribers

Discovering ABAP YouTube Channel