Abap RAP
Abap RAP
--------------------------------------------------------------------------------------------------------------------------------------------------
Dive into the world of ABAP Restful Application Programming (RAP) with a fresh perspective. This guide,
tailored for building a bookstore application, begins by familiarizing you with the ABAP development tools
and then swiftly moves into the practical aspects of application creation. You'll learn to craft a robust
database, develop intricate business objects, and seamlessly bind services, culminating in the development
of an intuitive user interface. Each step is presented with clarity and precision, offering you a smooth and
engaging learning experience
Overview:
Prepared by [email protected]
1. Designing a Database Table: Create a table for books, including fields like ISBN, title, author,
price,currency,created by,created on,last changed by and last changed on.
Prepared by [email protected]
@EndUserText.label : 'Book Store App Table 01'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zbook_astore01 {
key client : abap.clnt not null;
key isbn : abap.char(20) not null;
title : abap.char(100);
author : abap.char(50);
price : abap.dec(15,2);
currencycode : abap.cuky;
created_by : syuname;
created_at : timestampl;
last_changed_by : syuname;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;
}
2. Generating Demo Data: Write an ABAP class to populate your books table with sample data.
Prepared by [email protected]
CLASS zcl_generate_book_data_01 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_generate_book_data_01 IMPLEMENTATION.
ENDCLASS.
Add the logic for inserting the records by creating new class
Prepared by [email protected]
ENDCLASS.
CLASS zcl_generate_book_data_01 IMPLEMENTATION.
METHOD generat_demo_data.
TYPES:tt_bookstore TYPE STANDARD TABLE OF
zbook_astore01 WITH EMPTY KEY.
DATA(lt_bookstore) = VALUE tt_bookstore(
( isbn = '978-3-16-148410-0'
title = 'Title1'
author = 'Author1'
price = '19.01'
currencycode = 'USD' )
( isbn = '978-3-16-149410-1'
title = 'Title2'
author = 'Author2'
price = '16.01'
currencycode = 'USD')
( isbn = '988-3-16-148410-2'
title = 'Title3'
author = 'Author3'
price = '29.41'
currencycode = 'USD'
) ).
DELETE FROM zbook_astore01.
INSERT zbook_astore01 FROM TABLE @lt_bookstore.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
ENDMETHOD.
METHOD if_oo_adt_classrun~main.
generat_demo_data( ).
ENDMETHOD.
ENDCLASS.
Prepared by [email protected]
The below records are added successfully.
Prepared by [email protected]
3. Generating Transactional UI Services
Right-click your database table “ZBOOK_ASTORE01” and select “Generate ABAP Repository”
Prepared by [email protected]
Then Click “Next”
Prepared by [email protected]
Again “Next”.
● General
● Business Objects
○ Data Model
○ Behavior
● Service Projection,
● Business Service
○ Service Definition
○ Service Binding
Prepared by [email protected]
Prepared by [email protected]
Prepared by [email protected]
Prepared by [email protected]
Prepared by [email protected]
Prepared by [email protected]
Prepared by [email protected]
Click “Finish “
Prepared by [email protected]
Now it is generating artifacts
Prepared by [email protected]
4. Previewing the Application(Click Preview button): Test the application in a Fiori launchpad to ensure
functionality and usability.
Final Output
Day1
ABAP RESTful programming model
supports the development of
Prepared by [email protected]
The CDS data model and its annotations are then exposed as an OData service using the Service Adaptation
Description Language (SADL) technology.
transactional applications
in addition to read-only applications,
Add UI Annotation
Prepared by [email protected]
Create Service Binding
@UI: {
headerInfo: {
typeName: 'EMPData',
typeNamePlural: 'EMPData',
title: { type: #STANDARD, value: 'Empid' }
}
}
define view ZI_EmployeeBasicData
as select from ztemployee_001
{
@UI.facet: [
{
id: 'Empid',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Empid',
position: 10 }
]
@UI: {
lineItem: [ {
position: 10,
importance: #HIGH,
label: 'Emp ID' } ],
identification:[ { position: 10, label: 'Emp ID' } ]
}
key empid as Empid,
@UI: {
lineItem: [ {
position: 20,
label: 'Emp Name',
importance: #HIGH } ],
identification:[ { position: 10, label: 'Emp Name' } ]
}
@Search.defaultSearchElement: true
empname as Empname,
@UI: {
lineItem: [ {
position: 30,
label: 'Department',
importance: #HIGH } ],
identification:[ { position: 10, label: 'Department' } ]
}
department as Department,
Prepared by [email protected]
@UI: {
lineItem: [ {
position: 30,
label: 'Position',