Overview
You will learn
- How to generate the artifacts you need to create a RAP business service. (RAP is the ABAP RESTful Application Programming Model)
- You can then implement your business logic much more quickly than if you had to create each artifact by hand
Prerequisites
Prerequisites
- You have done one of the following:
- Tutorial: Create an SAP BTP ABAP Environment Trial User
- You have bought a licensed version of SAP BTP ABAP Environment
- You have installed ABAP Development Tools, latest version
Steps
Intro
Throughout this tutorial, object names may include a suffix or group number, such as ####. Always replace this with your own group number or initials.
For more information, see the links at the end of this tutorial.
Create a new package for this tutorial, by choosing New > ABAP Package.

step1a-new-package Enter the following then follow the wizard, choosing a new transport request:
- Name:
ZRAP_TRAVEL_#### - Description: Travel data generated
- Request description: Travel service RAP Generator

step1a-create-package 
step1b-new-tr - Name:
Choose your package, then choose New > Other Repository Object from the context menu.

step2a-choose-other Choose Database Table then Next.

step2b-choose-table Enter the following, then choose Next.
- Name:
zrap_travel_#### - Description: Travel Data Generated
- Name:
Choose the transport request, then choose Finish.
The table appears in a new editor.
Delete the code
key client : abap.clnt;and add the following:ABAPkey client : abap.clnt not null; key travel_uuid : sysuuid_x16 not null; 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 : 'zrap_travel_####.currency_code' booking_fee : /dmo/booking_fee; @Semantics.amount.currencyCode : 'zrap_travel_####.currency_code' total_price : /dmo/total_price; currency_code : /dmo/currency_code; description : /dmo/description; overall_status : /dmo/overall_status; local_created_by : abp_creation_user; local_created_at : abp_creation_tstmpl; local_last_changed_by : abp_locinst_lastchange_user; local_last_changed_at : abp_locinst_lastchange_tstmpl; last_changed_at : abp_lastchange_tstmpl;Format, save, and activate your table (
Shift+F1, Ctrl+S, Ctrl+F3).Optional: Check your table by clicking in the editor and choosing Open With > Data Preview.

step2c-data-preview You must include a key field
clientwith the typeabap.clnt.You must not use type
MANDTsince the generator will throw an error.In addition, you must include the following administrative fields with the following types.
These are known as reuse data elements.
ABAPlocal_created_by : abp_creation_user; local_created_at : abp_creation_tstmpl; local_last_changed_by : abp_locinst_lastchange_user; local_last_changed_at : abp_locinst_lastchange_tstmpl; last_changed_at : abp_lastchange_tstmpl;
For more information, see the SAP Help Portal: ABAP RESTful Application Programming Model: RAP Reuse Data Elements
Select your table and choose Generate ABAP Repository objects… from the context menu.

step3a-choose-rap-gen Enter the following and choose Next.
- Description: Travel data Generated
- Use case: ABAP RESTful Application Programming Model: UI Service
Enter the following:
- Data definition name:
ZI_TRAVEL_#### - Alias name: Travel

step3b-enter-data-def - Data definition name:
Enter the following information for each artifact, then choose Next:
Artifact Value Naming convention ABAP implementation class ZBP_I_TRAVEL_####ZBP_I_<entity>_<suffix>(BP = Behavior pool; I = interface view)Draft Table Name: ZRAP_TRAVEL_D_####Z<prefix>__<entity>_<suffix>(underscore is not permitted as a second or third character)CDS projection view entity ZC_TRAVEL_####ZC__<entity>_<suffix>(C = consumption view)CDS service definition ZUI_TRAVEL_####ZUI_<entity>_<suffix>(UI for e.g. Fiori app as opposed to a Web API)CDS service binding ZUI_TRAVEL_O4_####ZUI_<entity>_<OData version>_<suffix>Binding type: OData V4 - UIn/a The naming convention in general is as follows:
[/<namespace>/][<prefix>]_<object_name>_[<suffix>].For more information, see the SAP Help Portal: Naming Conventions for Development Objects
The system displays a list of objects that will be generated. Choose Next

step3c-preview-gen-output Choose the transport request, then choose Finish.
The artifacts are generated. You can now see them in the Project Explorer.

The service binding appears automatically in a new editor.

step4a-service-binding-unpublished Publish the service binding.

step4a-activate 
step4c-sb-publish You now have a fully-fledged business service for which a Fiori app (based on the Fiori Elements List Reporting template) can be generated. Test this in the Fiori Elements preview, by choosing the Travel entity set from the service binding, then choosing Preview.

step4d-sb-preview
The service appears in the Fiori Elements preview.
The table does not yet contain any data.
You can create a new Travel. IMPORTANT: There is no value help or any validation check. You need to build these manually. For more information, see the following tutorial group: SAP BTP ABAP Environment: Create and Expose a CDS-Based Data Model↓, parts three and four.
IMPORTANT: If you later add a new CDS view entity to the compositional structure of the data model, make sure that you also extend the behavior definition for the new BO entities. Otherwise your business service will show errors.
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.