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

ABAP RESTful Application Programming – Naming Conventions for Development Objects

The ABAP RESTful Application Programming Model (RAP) is a framework for developing cloud-ready business applications on SAP platforms. It emphasizes naming conventions for development objects, core concepts like business objects and queries, and tools for development and testing. RAP allows for modification-free extensibility, enabling developers to create upgrade-stable extensions in SAP S/4HANA Cloud.

Uploaded by

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

ABAP RESTful Application Programming – Naming Conventions for Development Objects

The ABAP RESTful Application Programming Model (RAP) is a framework for developing cloud-ready business applications on SAP platforms. It emphasizes naming conventions for development objects, core concepts like business objects and queries, and tools for development and testing. RAP allows for modification-free extensibility, enabling developers to create upgrade-stable extensions in SAP S/4HANA Cloud.

Uploaded by

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

ABAP RESTful Application Programming Model

What is RAP? The ABAP RESTful Application Programming Model (RAP) is an essential
element of ABAP Cloud, the ABAP development model for building clean core compliant,
cloud-ready business apps, services, and extensions on SAP BTP, SAP S/4HANA Cloud,
and SAP S/4HANA.
Prerequisites: You have installed ABAP Development Tools (ADT). You need an SAP BTP,
ABAP environment trial user or a license. Have Basic Knowledge of ABAP Core Data
Services (CDS).
Development Environment (IDE)
● You have installed ABAP Development Tools (ADT). SAP recommends to use the latest
version of the client installation. The ADT download is available on the update site
https://tools.hana.ondemand.com/.
● You have access to and a user account for the relevant space in SAP Cloud Platform
Cloud Foundry. More on this:
Authorizations
To create development artifacts described in this guide, you need the developer
authorization profile for the ABAP Environment.
Knowledge
Basic knowledge of
● ABAP Core Data Services (CDS)
● ABAP Objects.

ABAP RESTful Application Programming – Naming Conventions for


Development Objects

Defining and using naming conventions ensures consistency in the names used by all the
developers on a project. This post summarizes the naming conventions recommended by
SAP for the RAP Development Objects.

General Rules
The overall object name will be split into 3 parts.
[/<namespace>/][<prefix>]_<meaningful_abbreviation>_[<suffix>].

Namespace
[/<namespace>/]
For custom objects, the namespace can just be Z. Your project can also have a namespace
like ZAB_, etc.

Prefix
Prefix is used to differentiate between different types of the same development object. For
example, the Root Entity and Projection Entity can be differentiated using the prefix.

Meaningful Abbreviation
This can be any meaningful text separated by _ characters. For example, customer_name.

Suffix
Suffix can be used for additional differentiation between different types of development
objects. For example, a service binding with UI service can be named with suffix _V2 for
OData version 2 and _V4 for OData version 4.
With this explanation, let us understand how the RAP development objects can be named.
For the examples, the namespace used is ZJP_.

ABAP Dictionary Objects


Object Type Prefix Suffix Example

Database Tables – Persistent A_ ZJP_A_Customer

Database Tables – Draft D_ ZJP_D_Customer

CDS Objects
Suffi
Object Type Prefix Example
x

Interface CDS Entity (Root CDS


I_ ZJP_I_Customer
Entity)

Base CDS Entity R_ ZJP_R_Customer

Projection CDS Entity C_ ZJP_C_Customer


Suffi
Object Type Prefix Example
x

Behavior Definition – Root Same as root CDS Entity ZJP_I_Customer

Same as projection CDS


Behavior Definition – Projection ZJP_C_Customer
Entity

Same as the related CDS


Metadata Extension ZJP_C_Customer
entity

Business Services
Suffi
Object Type Prefix Example
x

UI_ ZJP_UI_Customer
Service Definition
or No Prefix ZJP_Customer

Service Binding for UI Service with OData


UI_ _O2 ZJP_UI_Customer_O2
V2

Service Binding for UI Service with OData


UI_ _O4 ZJP_UI_Customer_O4
V4

Service Binding for Web API API_ ZJP_API_Customer

Source Code Objects


Object Type Prefix Suffix Example

Behavior Pool BP_ ZJP_BP_Customer

Handler Class LHC_ ZJP_LHC_Customer

Saver Class LSC_ ZJP_LSC_Customer

The naming conventions can also be checked in the ABAP Flight Reference Scenario. This
contains many reference services which can help you learn more about ABAP RAP. Check
for package /DMO/FLIGHT_LEGACY.
Core Concepts in RAP
Business Object

Common term to represent a real-world business entity – such as Product, Travel,


or SalesOrder – in enterprise application development.

On a conceptual level, a business object (BO) consists of a data model, aka composition
model, and its transactional behavior. In general, a business object contains:

 several nodes, for example, the root node SalesOrder and the child
nodes SalesOrderItems and ScheduleLine
 standard transactional operations for creating, updating, and deleting business data
 non-standard, application-specific transactional operations
RAP offers different runtime implementation types for the implementation of the transactional
business objects' behavior. The main ones are the managed BO
runtime implementations and the unmanaged BO runtime implementations – typically used
for greenfield and brownfield implementations respectively.

Query
A query is the connecting interface for read-only access to the database in OData services. It
is used for list reports or analytical reports to process data.
As the non-transactional counterpart of a business object, it consists of a data model,
generic and modeled query capabilities and a runtime. This threefold division is known from
the BO concept. However, a query provides only read access to the database. Its runtime
never modifies data, but only executes structured data retrieval, for example for filtering.

Business Service
The ABAP development platform can act in the roles of a service provider and a service
consumer (such as SAP Fiori UI client).
In the context of the ABAP RESTful application programming model, a business service is a
RESTful service which can be called by a consumer. It is defined by exposing its data model
together with the associated behavior. It consists of a service definition and a service
binding.

Implementation Languages
ABAP Core Data Services (CDS)
ABAP CDS offers a data modelling infrastructure for defining semantically rich data models
and easy access to advanced SAP HANA libraries and features using CDS table functions.
The data definition language of ABAP CDS has been enhanced to natively support the
definition of composition and behavior models of RAP BOs.

Modern ABAP Language


The ABAP language has gone through various evolutions since its inception. Its recent
modernization – with a focus on simplification – has turned it into a more declarative and
expression-oriented language, which allows developers to write more simple and concise
ABAP code using language features such as inline declarations with type inference, new
operation constructors, and filtering, grouping and virtual sorting operations for internal
tables. The ABAP language has also been extended with the Entity Manipulation Language
(EML), which is used to control the transactional behavior of RAP BOs.

Entity Manipulation Language (EML)


EML offers an SQL-like syntax that allows developers to implement the transactional
behavior of RAP business objects. It also offers a type-safe, API-based access to RAP BOs
within and outside the RAP context.

Tools
ABAP Development Tools in Eclipse

The ABAP Development Tools (ADT) is the integrated development environment on the well-
known Eclipse platform for all standard ABAP development, quality assurance, and
supportability tasks, both on on-premise and on cloud ABAP systems.
ADT offers a modern development toolset with many goodies such as syntax highlighting,
code completion, code templates, advanced search and navigation, and quick fixes to
increase developer productivity. Various eclipse-based editors, views, and features are
provided. For instance, the Relation Explorer view is provided to explore the structure and
capabilities of development objects such as RAP BOs. The ADT wizard Generate ABAP
Repository Objects can be used to generate all required RAP artefacts for an OData service
with managed implementation type based on a database table.
Moreover, powerful options and tools for testability and troubleshooting are provided in ADT.

Clean code checks for ABAP – Cloud Edition

Now there is a new free and open source version of code pal for ABAP cloud checks, which
(as the name already states) is cloud-enabled, thus the checks can now be executed in SAP
BTP ABAP Environment. Beyond this all checks are now remote-enabled and can be run in
the remote ABAP test cockpit scenario. Additionally, to speed up your code adaptation to
Clean ABAP for many findings quick fixes are provided in the ABAP development tools for
Eclipse to automate your adjustment tasks.
Let’s take a look at how you can use code pal for ABAP cloud checks in your SAP BTP,
ABAP environment system to check your code for Clean ABAP.
Technical Prerequisites
The code pal for ABAP cloud checks can be executed in SAP BTP, ABAP environment.
If you want to check your on-premise releases (or SAP S/4HANA Cloud, private edition
systems) with code pal for ABAP cloud checks you can do it remotely from SAP BTP, ABAP
environment, see also the blog ABAP Test Cockpit in the Cloud – What is already
possible for more details.
You need abapGit to pull the checks from the Git repository into your system. For SAP BTP,
ABAP environment systems install abapGit plugin for ABAP development tools for Eclipse.

Install code pal for ABAP cloud checks via


abapGit

In the SAP BTP, ABAP environment system you will use ABAP development tools for Eclipse
and abapGit plugin to install code pal for ABAP cloud checks.
Create a new package in the /CC4A/ namespace, and name it for example CODE_PAL. The
source code of code pal for ABAP checks is located in the /CC4A/ (Clean Code for ABAP)
namespace, so that collisions with Y*/Z* objects from other projects are avoided.
Open abapGit Repositories View in your ABAP development tools for Eclipse:

Click the „+“ button to link the new abapGit repository:

and enter the path to the GitHub repository https://github.com/SAP/code-pal-for-abap-


cloud, containing the code pal for ABAP cloud checks:
In the next step enter the name of your newly created package /CC4A/CODE_PAL and
check the Pull after link checkbox:

Finally, after completing the abapGit plugin wizard, the code pal for ABAP cloud checks
repository will be linked:

and the source code of the check implementations pulled under your newly created package
/CC4A/CODE_PAL:

Just activate all objects, and the code pal for ABAP cloud checks are ready to use.

Execute code pal for ABAP cloud checks


The check variant /CC4A/CODE_PAL_FULL contains all available code pal for ABAP cloud
checks:
There is also the package /CC4A/CODE_PAL_TEST_OBJECTS, which you can use to see
how the code pal for ABAP cloud checks work. Just select this package and use the context
menu Run ABAP Test Cockpit With…
Enter the ATC check variant /CC4A/CODE_PAL_FULL and click the OK button to execute
the ATC run:

The ATC Problems View provides the check results concerning violations of the Clean ABAP
rules in the source code objects of the test package:

Now you can select your own development package(s) or set(s) of the development objects
which you want to check and execute the code pal for ABAP cloud checks over these
objects.
Use quick fixes
If you take a look at the ATC results, the yellow bulb icons before the ATC findings indicate
that for these ATC findings the quick fixes in ABAP development tools for Eclipse are
available, which allow to fix these findings in an automated way.

By navigating from an ATC finding to the corresponding source code line you can see the
examples of the violations of the Clean ABAP rules and can try out the corrections, which
are provided by quick fixes using the Ctrl + 1 shortcut.
In the following example the code pal for ABAP cloud check detects the unnecessary self
reference, which can be removed via the quick fix:

In the next example the check finds a chain declaration, which can be replaced with
separate declarations of the variables involved using the quick fix:
In the last example the values are allocated more than once within one statement and the
quick fix will break the assignment chain into multiple statements:

You can also use mass-enabled quick fixes (context menu Recommended Quick Fixes will
start the wizard) to adapt all ATC findings at once:
Testability
As an application developer, you want to verify the behavior of an application as a whole by
writing and executing unit, scenario, and integration tests.
The ABAP platform and ADT provide powerful frameworks and tools to ensure high quality
applications throughout the software development lifecycle. These include the ABAP Test
Cockpit for performing static checks, the ABAP Unit test framework for testing, various Test
Doubles Frameworks – e.g., for ABAP, SQL, CDS, and RAP business objects – for isolating
the code under test, and the local OData client proxy for the API-based testing of OData
services.
Troubleshooting
As an application developer, you want to be able to search for the origin of occurring
semantic, functional, and performance issues and fix them.
ADT supports you in this by offer several advanced analysis and troubleshooting options and
tools in the form of ADT views, for instance:
 ABAP Debugger – used for troubleshooting the business logic implement in the
backend.
 ABAP Cross Trace – used for a semantic end-to-end analysis of OData-based
services or business objects built with RAP.
 ABAP Profiling – used for analyzing the runtime behavior of an ABAP program.
Various ABAP CDS Tools – used to define and analyze CDS-based data models.

Extensibility
About the RAP Extensibility

RAP provides built-in, modification-free extensibility options for data models, behaviors, and
nodes of RAP BOs and service definitions.
Based on these RAP extensibility options, full-fledged and upgrade-stable extensions can be
built on SAP S/4HANA Cloud using developer extensibility, where previously only limited key
user extensibility options were available.

You might also like