0% found this document useful (0 votes)
111 views

Abap RAP

This document provides steps to create a bookstore application using ABAP RESTful Application Programming (RAP). It involves creating an ABAP package, designing a database table to store book data, generating sample data, and generating transactional UI services. The application allows previewing book data in a Fiori launchpad to ensure functionality and usability. The 6 steps outlined are: 1) initial setup, 2) creating a package, 3) database table design, 4) business object development, 5) service definition and binding, and 6) UI generation.

Uploaded by

tecsafina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Abap RAP

This document provides steps to create a bookstore application using ABAP RESTful Application Programming (RAP). It involves creating an ABAP package, designing a database table to store book data, generating sample data, and generating transactional UI services. The application allows previewing book data in a Fiori launchpad to ensure functionality and usability. The 6 steps outlined are: 1) initial setup, 2) creating a package, 3) database table design, 4) business object development, 5) service definition and binding, and 6) UI generation.

Uploaded by

tecsafina
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Navigating ABAP RAP Stepwise Blueprint for Crafting Your First Bookstore App

--------------------------------------------------------------------------------------------------------------------------------------------------

Creating an ABAP Package: Define a package for your bookstore application.

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:

1. Initial Setup: Begin by setting up the ABAP development environment in Eclipse.


2. Create a New ABAP Package: Define a new package for organizing the application components.
3. Database Table Design: Create a database table to store essential book data, ensuring it captures
necessary details like ISBN, title, author, and more.
4. Business Objects Development: Proceed to create and implement business objects, which are
central to the application's functionality.
5. Service Definition and Binding: Define a service for the application and bind it, enabling
interaction with the user interface.
6. UI Generation: Lastly, focus on generating a user interface, ensuring it's user-friendly and
effectively displays the stored book data.

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

CLASS zcl_generate_book_data_01 DEFINITION


PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES :if_oo_adt_classrun.
CLASS-METHODS:generat_demo_data.
PROTECTED SECTION.
PRIVATE SECTION.

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.

Save and activate the changes.

Select the class and Run your console application

Prepared by [email protected]
The below records are added successfully.

Click the preview and display the inserted records

Prepared by [email protected]
3. Generating Transactional UI Services

Right-click your database table “ZBOOK_ASTORE01” and select “Generate ABAP Repository”

Select Generator screen will appear in the ABAP Cloud System

Prepared by [email protected]
Then Click “Next”

Prepared by [email protected]
Again “Next”.

Navigate through the wizard tree the below options

● 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

Activate and publish the service binding

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

● SAP HANA-optimized OData services for SAP Fiori applications


based on

● core data services (CDS) views and


● covers analytical, transactional, and search application processes
Main Two Scenario
● read-only applications
● transactional applications
read-only applications
What does read only applications?

● CDS data model


● Application-specific analytics
● Search annotations

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,

● require the creation of a business object


● a behavior definition and implementation for the handling of
o create,
o read,
o update, and
o delete (CRUD) operations as well as
o in ABAP.
Simplified step-by-step guide to create a read-only application using RAP:
Set Up Your Development Environment:
● Ensure you have access to an SAP system with the latest ABAP environment.
● Use the ABAP Development Tools (ADT) in Eclipse as your IDE.
Create a New ABAP Package:
● In ADT, create a new ABAP package to contain your RAP objects.
Define Your Data Model:
● Create a Core Data Services (CDS) view to define your data model.

Add UI Annotation

Create service definition to expose Employee Entity

Prepared by [email protected]
Create Service Binding

Publish Service Binding.


Prepared by [email protected]
@AbapCatalog.sqlViewName: 'ZVEMPBASIC'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Employee Basic Data'
@Search.searchable : true

@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',

You might also like