100% found this document useful (1 vote)
33 views26 pages

ABAP Fundamentals for Developers

The document provides an overview of the ABAP platform and core concepts for new ABAP developers. It discusses what ABAP is, why learn ABAP, ABAP highlights and statistics, core concepts like the application server architecture and client concept, and introduces the ABAP RESTful application programming model.

Uploaded by

Venky Venkatesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
33 views26 pages

ABAP Fundamentals for Developers

The document provides an overview of the ABAP platform and core concepts for new ABAP developers. It discusses what ABAP is, why learn ABAP, ABAP highlights and statistics, core concepts like the application server architecture and client concept, and introduces the ABAP RESTful application programming model.

Uploaded by

Venky Venkatesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ABAP for Newbies

Get an overview of the ABAP pla3orm core concepts and all basic knowledge for your first development steps.

Why Learn ABAP?


What is ABAP?
ABAP technology is the solid long?me founda?on for SAP’s solu?on por3olio. Its proven robustness, scalability and
extensibility makes it the pla3orm of choice for running mission-cri?cal business processes.
It is the underlying technology of SAP’s tradi?onal Business Suite, SAP’s flagship solu?on SAP S/4HANA, and other
forthcoming innova?ve solu?ons such as next-genera?on data warehouse SAP BW/4HANA. ABAP technology is
also available as a standalone pla3orm for custom development of modern ABAPbased business applica?ons. SAP
customers and partners also have a long tradi?on of building custom code and add-ons that run on the ABAP
technology pla3orm.
It is also a complete applica?on development and run?me pla3orm. It combines: the innova?on poten?al of SAP’s
in-memory database SAP HANA on the back end; the proven reliability and robustness of the ABAP server; and a
digital user experience through SAP’s UI technology SAP Fiori. The ABAP technology is con?nuously extended to
serve new business scenarios and innova?ve applica?on development in a first approach.

ABAP Highlights
ABAP is a founda?on for a large variety of SAP, partner, and customer developments. ABAP runs produc?vely in
more than 100,000 SAP customer systems, where it enables enterprise-ready business applica?ons and processes,
and reduces total cost of development due to its integrated, self-compiling nature. ABAP has a huge customer and
partner community.
ABAP Pla3orm
>100.000 installed produc?ve SAP systems based on ABAP
>64.000 custom ABAP objects per average SAP system

>5 million registered ABAP developers

Highlights
Modern ABAP language, tailor-made for effec?ve business programming
Proven, highly scalable, and robust applica?on server with mul?-layer architecture and powerful transac?on
management
Central development on the server with integrated source code and version management

Built-in vendor-independent database support

Superior development environment and ABAP tools for the whole development lifecycle provided in
Eclipse
l l
l l

Core Concepts
What is the general architecture of ABAP?
The Applica?on Server ABAP (AS ABAP) consists of three layers: presenta?on, applica?on, and database. The layer
division is purely logical. In fact, all three layers can actually run on a single computer.
The database not only contains the user data, but also the en?re program code of the ABAP Applica?on Server and
applica?on programs, all administra?ve data etc. The programs you develop are stored in the ABAP schema of the
system.
The applica?on layer consists of one or more AS ABAP instances, a single Message Server, which is responsible for
communica?on and load distribu?on within this layer, and a single Enqueue Server, which manages locks. The
ABAP programs and all the development tools run in the applica?on layer. ABAP Dispatcher distributes the
requests to the work processes (WP) within an AS ABAP. A WP processes your program and owns a database
connec?on so that you don’t need to take care of database handling (e.g. open/close database connec?ons). A WP
is assigned to you only for the ?me of program processing and a_erwards it is free for another user. This
architecture is robust and scalable. There is no such thing as crashing the whole engine in ABAP by a severe syntax
error in your program. Beyond this ABAP systems and external programs can communicate with one another
through different protocols like RFC, TCP/IP, HTTP and OData.
The presenta?on layer represents UI and is responsible for the screen display. This layer receives user entries – that
is, mouse-clicks and keyboard input – and passes them on to the applica?on layer. Furthermore, it receives data
from the applica?on layer and displays it to the user. When wri?ng a business applica?on you should use SAP Fiori
UI as a state-of-the-art user interface. When developing in ABAP you may also encounter browser-based Web
Dynpro ABAP/Floorplan Manager technology or Dynpro technology. Before SAP Fiori, Web Dynpro for ABAP was
the SAP standard UI technology for developing Web applica?ons in the ABAP environment. Dynpros are the
classical user interfaces of most ABAP-based SAP programs and run in the SAP GUI.

Why and how does Applica:on Server ABAP ma>er for you as developer?
In general, you develop on a central server in ABAP. Thus, you require access and developer authoriza?on for the
AS ABAP. All the tools for the whole development lifecycle are integrated there and are also part of the server.
You write your programs using the ABAP Development Tools. When you choose Save, the ABAP editor stores your
program in the database. You then retrieve it by name: you don’t have to deal with program files in ABAP; the
server does it all for you. Usually many developers are working on the same server. While you write your source
code in the editor this development object is locked for you. When you choose the Save-bueon the inac?ve
version of the development object is created. This is visible for all developers on the server and they can change it.
Once you press Ac?vate bueon an ac?ve version of the development object is created and other programs can
access it.
Your advantages:

You don’t need to deal with version management: the server does it for you
You always use the latest sources

The incompa?bili?es become visible very early: at ac?va?on of your source code

No need for a separate system to test the interac?on of source code from different developers
Typical experience when working with the AS ABAP: Many things that developers or quality managers usually must
care about are already provided and you can concentrate on your daily job: business programming.
Why and how to connect to integrated so?ware logis:cs on the ABAP server?
All ABAP development objects are stored in the database of the system. You don’t have to copy a program file
manually if you need it elsewhere. The ABAP server provides the built-in mechanism (change and transport
management system, CTS) to transport development objects through the system landscape. Besides this, the
proper structuring of development objects becomes par?cularly important if you work in a team on a
development project.
Every development object in ABAP belongs to a package. Packages organize development objects and handle their
connec?on to the AS ABAP so_ware logis?cs. That is a package is like a folder in a way. The transport layer is an
important concept in the ABAP so_ware logis?cs. It refers to the transport path a package should take in a system
landscape. The usual landscape has at least three system layers:

You develop an object in the development system and test it in the consolida?on system. When all tests are
successful you transport your tested development objects to the produc?ve system. You define this path (transport
layer) as an aeribute of a package and in this way the des?na?ons of your development objects are clear from the
very beginning of your development.
Besides this you need to assign your package and its content (ABAP development objects) to a par?cular transport
request. As soon as you release the relevant transport request, your object will be transported to the next system
on the transport layer. The only excep?on to this rule is the package $tmp. You can store there your local
developments, which don’t need to be transported.
Learn more: Create an ABAP Package tutorial

What is the ABAP Repository and ABAP Dic:onary/Data Dic:onary?


The ABAP Dic?onary (also called DDIC, which again stands for Data Dic?onary) centrally describes and manages all
the data defini?ons (meta data) used in the ABAP system like data types, database tables and views.

Learn more: ABAP Data Dic?onary tutorial


ABAP Repository is part of the standard database of ABAP applica?on server that contains all ABAP development
objects: programs, classes, etc. Each repository object is assigned to a package and hence is connected to the ABAP
transport management system.
Learn more: Exploring the ABAP Repository tutorial
What is the client concept?
As soon as you create your first ABAP project and connect to an ABAP system, you need not only to provide your
user data but also a Client. What is it?

An SAP system holds a large bunch of business data and applica?ons that work with this data. These applica?ons
represent the business processes of a company. Client concept organizes these data according to organiza?onal
units and the business needs of a company. For example, the different interna?onal subsidiaries of a global
company may need to implement the same business processes differently in their systems.
The client is the highest organiza?onal unit in an SAP system and a self-contained unit with its own master data.
The client is the first key field in most relevant tables of an SAP system, you always logon in a SAP system on to a
par?cular client and therefore the client-specific data are automa?cally selected with SELECT in a program without
specifying it in the WHERE-condi?on. You can even keep the data of different clients in one table and s?ll keep
them apart as if they were stored in different tables.

Before Developing in ABAP


What is the ABAP RESTful Applica:on Programming Model?
In ABAP you develop using the state-of-the-art object-oriented ABAP language. This contains special efficient
features for business programming – such as business data types, mass data handling, and advanced table
opera?ons. The ABAP language enables you to write simple and concise expressionoriented ABAP code and
supports inline code documenta?on with ABAP Doc.
Today, the ABAP pla3orm also comes with the modern and efficient ABAP RESTful applica?on programming model
(RAP) for the development of SAP Fiori business apps and Web APIs in SAP BTP, SAP S/4HANA, and SAP S/4HANA
Cloud, op?mized for the SAP HANA database.
Learn more: Modern ABAP Development with the ABAP RESTful Applica?on Programming Model (RAP)
What ABAP tools are there for the development lifecycle?
You write your ABAP code in the Eclipse-based integrated development environment ABAP
Development Tools (ADT). ADT offers you superior open and extensible ABAP toolset for your whole development
lifecycle, which enables you to develop with high produc?vity: powerful source code editor with fast search and
naviga?on, Quick Fixes and Quick Assists, refactoring support, test-driven development with ABAP Units and ABAP
Test Doubles, integrated quality assurance and troubleshoo?ng tools, version management and lifecycle
management tools which help to transport your code through the system landscape. In some development
projects, you may also get in touch with the classic SAPGUI-based ABAP Workbench.
Learn more: Get started with the ABAP Development Tools
ABAP Pla3orm offers you a broad variety of tools which support you during the whole development lifecycle. Most
of them are integrated into ADT. With ABAP Test Cockpit (ATC) you can run sta?c code checks to find func?onal,
performance and security bugs in your code. No maeer what sort of problem you face in ABAP, the ABAP powerful
troubleshoo?ng tools like ABAP Debugger, ABAP Profiler, ABAP Feeds for short dumps, run?me SQL performance
analysis in produc?ve ABAP systems with SQL Monitor help you to track down and understand the cause and find
the solu?on.
Learn more: ABAP Tes?ng and Analysis Community

What extensibility op:ons are there?


Extensibility op?ons allow you to add value to ABAP applica?ons either by doing easy changes directly in the
applica?on (key user extensibility), or implemen?ng cloud-ready and upgrade-stable extensions onstack with
Embedded Steampunk (developer extensibility), or by developing side by side extensions on SAP Business
Technology Pla3orm.
Learn more: ABAP Extensibility Community

What is SAP S/4HANA Cloud ABAP Environment (aka Embedded Steampunk)?


SAP S/4HANA Cloud ABAP Environment (aka Embedded Steampunk) offers SAP customers and partners the
opportunity to build ?ghtly coupled extensions running directly on the S/4HANA Cloud technology stack. This new
extensibility op?on complements the exis?ng key user extensibility and sideby side extensibility op?ons.
Learn more: SAP S/4HANA Cloud ABAP Environment Community

ABAP Environment in SAP Business Technology PlaNorm (BTP)


SAP BTP ABAP Environment is the SAP Pla3orm-as-a-Service (PaaS) offering for ABAP development that enables
developers to leverage their tradi?onal on-premise ABAP know-how to develop and run ABAP applica?ons in the
SAP Business Technology Pla3orm, either as an extension to SAP so_ware or as standalone applica?ons.
Learn more: SAP BTP ABAP Environment Community
Start Developing in ABAP
How do I get access to a free trial?
Ready to start with ABAP development? Then you definitely need access to the free developer edi?on. You can
either try ABAP developer edi?on on SAP HANA database as Cloud appliance or download ABAP developer edi?on
on SAP ASE database.
Get it in the ABAP Development Community
Get started with ABAP development
Now you can start to develop in ABAP. By execu?ng the small set of simple and short online tutorials such as Get
started with ABAP development, you can learn how to create your first ABAP project, display database content and
tune SQL statements by using Data Preview and SQL Console, create your first “Hello World” ABAP applica?on,
your first ABAP class and DDIC structures and elements and document your ABAP code using ABAP Doc.
Create your first Core Data Service (CDS)
CDS is an extension of the ABAP Dic?onary that allows you to define seman?cally rich data models in the database
and to use these data models in your ABAP programs. CDS is a central part to delegate the processing of data-
intensive computa?on from the applica?on server to the database (i.e. SAP HANA) in ABAP applica?ons. Execute
the online tutorial Create a CDS View to create your first CDS View.

Where can I get more informa:on and help?


1) Visit these ABAP community topic pages:

ABAP Development
ABAP Tes?ng and Analysis

ABAP Connec?vity
ABAP Extensibility

SAP BTP ABAP Environment


SAP S/4HANA Cloud ABAP Environment

2) Learn how to use the ABAP Documenta?on: Go to SAP Help Portal and type “ABAP" in the search field.
The ABAP node provides a link to the ABAP Keyword Documenta?on, which describes the syntax and meaning of the
keywords of the ABAP language, its frameworks and the associated system classes. This is the most relevant look up
documenta?on source to accompany you during development. One way to access it is by marking the relevant command
in the ABAP editor and pressing the F1 bueon.

The product related link e.g. SAP S/4HANA offers product-related (like applica?on help) and release-dependent (like
release notes) documenta?on, also installa?on and upgrade guides and so on.
For you as developer the Development Informa?on under Developíng on the ABAP pla3orm is the most relevant entry
point, where you get detailed informa?on about all components of ABAP Applica?on Server, its core concepts,
features and tools.
Write Smart ABAP – Not Boring ABAP!
Many developers are using the new, modern and powerful enhancements to the ABAP language yet as a result most of
these modern features are not leveraged in the applica?ons which, I believe, were made with an inten?on to modernise the
language as well as simplify the development and maintenance of the applica?on lifecycle.

The inten?on of this blog series is to highlight the benefits of func?onal programming by embracing the new ABAP features
(and some old techniques as well which are powerful enough but not very popular for reasons unknown) to write smart,
exci?ng, reusable, sustainable code and avoid wri?ng boring, repe??ve (o_en viola?ng the Don’t Repeat Yourself (DRY)
principle or the Separa?on of Concern (SoC) principle), redundant, old fashioned (and o_en procedural) code which is a
nightmare to maintain and/or to be able to extend these applica?ons.

Back to the Future


We will start with one of the powerful features which is already “old” i.e. it’s been there in the system surely for more than
a decade but I do not see many developers using it at all – it is the Resumable Excep?on. I will demonstrate the handling
of a same business scenario excep?on with and without its Resumable op?on to understand the difference and also the
benefits of a modern development design which leverages these powerful features ul?mately saving ?me & effort which
equals money to the customer in the long run.

Business Scenario
The business scenario is quite simple. A list of employees are to be reported with their respec?ve Employee Group
(EMPTYP), Salary amount (SALARY) and Phone Numbers (PHONE).

However, for EMPTYP = ‘Contractor’, there will be no salary record found in the system (as it is managed by their
recruitment agencies) however other informa?on of these contractors like Employee Type and Phone Numbers are s?ll
required to be reported.

Also, if Employee Group (EMPTYP) data is not found in the system (data not maintained), they need to be reported as
excep?ons for those employees.

Technical Design
In the context of the business scenario, the internal table we will be looping on contains References to employee objects
for all Types of employees (Employee Type) i.e. Full-Time, Part-Time, Contractors, Casual and so on.

In each itera?on of the loop, we will read all required employee data and move them to build another internal table to
display the results.

Things to note in the design phase:

The contractor group has no pay details stored in the system as they are managed externally – the business however
would s?ll like to see the other available data in the system for them.
Enter Excep?on Objects – we could treat this scenario as an excep?on and handle them separately however we
need to make sure that the excep?on object is managed in a way to be able to s?ll process the employee
aeributes for which the data is available.
As the aeribute Employee Type is quite important to the organisa?on, any employee with missing Employee Type record
needs to reported as excep?ons so that their master data can then be maintained.
Sounds like a straight forward case of an Excep?on Object which needs to be handled and then excluded from
processing of the report.

Implementa>on
Excep-on handling WITH the Resumable addi-on

Report ztest.

CLASS lcl_employee DEFINITION FINAL CREATE PUBLIC.

PUBLIC SECTION.

TYPES: BEGIN OF empl_data,


empid TYPE int4, "Employee ID emptyp TYPE string, "Org Assignment
data
salary TYPE decfloat16, "Pay data
phone TYPE numc10, "Communica?on data END OF empl_data, empl_data_t TYPE
SORTED TABLE OF empl_data WITH UNIQUE KEY empid.

METHODS constructor IMPORTING VALUE(i_empid) TYPE int4.


METHODS get_data RETURNING VALUE(rs_result) TYPE empl_data RAISING
RESUMABLE(cx_no_data_found).

PRIVATE SECTION.

DATA emp_id TYPE int4.

METHODS get_emptyp RETURNING VALUE(r_result) TYPE string


RAISING cx_no_data_found.
METHODS get_salary RETURNING VALUE(r_result) TYPE decfloat16
RAISING RESUMABLE(cx_no_data_found).
METHODS get_phone RETURNING VALUE(r_result) TYPE numc10.
METHODS get_emp_id RETURNING VALUE(r_result) TYPE int4.
ENDCLASS.

CLASS lcl_employee IMPLEMENTATION.

METHOD constructor. me->emp_id = i_empid. ENDMETHOD.

METHOD get_data. rs_result = VALUE #( empid = me->get_emp_id( ) emptyp = me->get_emptyp( )


salary = me->get_salary( ) phone = me->get_phone( )
). ENDMETHOD.

METHOD get_emptyp. r_result = SWITCH #( me->get_emp_id( ) WHEN 1 THEN |Full-Time|


WHEN 2 THEN |Part-Time|
WHEN 3 THEN |Contractor|
WHEN 4 THEN |Casual| ELSE THROW cx_no_data_found(
rel_proc_id = CONV #( me->get_emp_id( ) ) )
). ENDMETHOD.

METHOD get_phone. r_result = SWITCH #( me->get_emptyp( ) WHEN `Full-Time` THEN |1234567890|


WHEN `Part-Time` THEN |5678901234|
WHEN `Casual` THEN |7890123456| ELSE |0399999999|
). ENDMETHOD.

METHOD get_salary. r_result = SWITCH #( me->get_emptyp( ) WHEN `Full-Time` THEN 50000


WHEN `Part-Time` THEN 25000
WHEN `Casual` THEN 5000
ELSE THROW RESUMABLE cx_no_data_found(
rel_proc_id = CONV #( me->get_emp_id( ) ) )
). ENDMETHOD.

METHOD get_emp_id.
r_result = me->emp_id.
ENDMETHOD.
ENDCLASS.

DATA extract_t TYPE lcl_employee=>empl_data_t. DATA error_t TYPE


string_table.

START-OF-SELECTION.

DATA(all_employees_t) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ).

LOOP AT all_employees_t REFERENCE INTO DATA(dref).


TRY.
INSERT NEW lcl_employee( dref->* )->get_data( ) INTO TABLE extract_t.

CATCH BEFORE UNWIND cx_no_data_found INTO DATA(lx_no_data).


IF lx_no_data->is_resumable = abap_true. "Resumable Excep?on was raised
RESUME.
ELSE.
"Non-Resumable Excep?on was raised error_t = VALUE #( BASE error_t ( lx_no_data->get_text( )
) ).
ENDIF.
ENDTRY. ENDLOOP.

cl_demo_output=>new( )->write( extract_t )->write( error_t )->display( ).

Excep?on handling WITHOUT the Resumable addi?on


The implementa?on of the Local Class (below code snippet) needs to be slightly different in this case as the calling program
would want to know for which specific data the excep?on was raised whereas the above implementa?on (with the
Resumable addi?on) simply does not care.

CLASS lcl_employee DEFINITION FINAL CREATE PUBLIC.

PUBLIC SECTION.
TYPES: BEGIN OF empl_data,
empid TYPE int4, "Employee ID emptyp TYPE string, "Org Assignment
data
salary TYPE decfloat16, "Pay data
phone TYPE numc10, "Communica?on data END OF empl_data, empl_data_t TYPE
SORTED TABLE OF empl_data WITH UNIQUE KEY empid.

METHODS constructor IMPORTING VALUE(i_empid) TYPE int4. METHODS get_emptyp


RETURNING VALUE(r_result) TYPE string
RAISING cx_no_data_found.
METHODS get_salary RETURNING VALUE(r_result) TYPE decfloat16
RAISING cx_no_data_found.
METHODS get_phone RETURNING VALUE(r_result) TYPE numc10. METHODS get_emp_id RETURNING
VALUE(r_result) TYPE int4.

PRIVATE SECTION. DATA emp_id TYPE int4.

ENDCLASS.

CLASS lcl_employee IMPLEMENTATION.

METHOD constructor. me->emp_id = i_empid. ENDMETHOD.

METHOD get_emptyp. r_result = SWITCH #( me->get_emp_id( ) WHEN 1 THEN |Full-Time|


WHEN 2 THEN |Part-Time|
WHEN 3 THEN |Contractor|
WHEN 4 THEN |Casual| ELSE THROW cx_no_data_found(
rel_proc_id = CONV #( me->get_emp_id( ) ) )
). ENDMETHOD.

METHOD get_phone. r_result = SWITCH #( me->get_emptyp( ) WHEN `Full-Time` THEN |1234567890|


WHEN `Part-Time` THEN |5678901234|
WHEN `Casual` THEN |7890123456| ELSE |0399999999|
). ENDMETHOD.

METHOD get_salary. r_result = SWITCH #( me->get_emptyp( ) WHEN `Full-Time` THEN 50000


WHEN `Part-Time` THEN 25000
WHEN `Casual` THEN 5000 ELSE THROW cx_no_data_found(
rel_proc_id = CONV #( me->get_emp_id( ) ) )
). ENDMETHOD.

METHOD get_emp_id.
r_result = me->emp_id.
ENDMETHOD.

ENDCLASS.

And the calling program (the consumer) is different as well.


Report ztest.

DATA extract_t TYPE lcl_employee=>empl_data_t. DATA error_t TYPE

string_table. START-OF-SELECTION.

DATA(all_employees_t) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ).

LOOP AT all_employees_t REFERENCE INTO DATA(dref).

DATA(ref) = NEW lcl_employee( dref->* ).


TRY.
DATA(extract) = VALUE lcl_employee=>empl_data( empid = ref-
>get_emp_id( ) emptyp = ref->get_emptyp( ) phone =
ref->get_phone( )
).

CATCH cx_no_data_found INTO DATA(lx_no_data).


error_t = VALUE #( BASE error_t ( lx_no_data->get_text( ) ) ).
CONTINUE.
ENDTRY.

"Note that the call to the method GET_SALARY( ) is separated


TRY. extract = VALUE #( BASE extract salary = ref-
>get_salary( )
).
CATCH cx_no_data_found INTO lx_no_data. ENDTRY.

INSERT extract INTO TABLE extract_t. ENDLOOP.

cl_demo_output=>new( )->write( extract_t )->write( error_t )->display( ).

Flexibility of the Resumable Excep>ons


Now another similar requirement comes along in the near future but this ?me the Contractor group is required to be
excluded from the report when their salary records are not found in the system and they need to be reported as excep?ons
as well. All other requirements remain the same.
New Implementa,on
– Changes to the Resumable Excep-on handling
To meet this requirement, the developer who used the Resumable op?on achieves it very quickly by making minimal
changes to the calling program as seen in the code snippet below.

The only change he does is that he handles the Resumable excep?on (that was raised by the method) as a normal excep?on
object without having to modify the local class; but most importantly, he does not disturb the main processing of the calling
program (the consumer).

Report ztest_new.

DATA extract_t TYPE lcl_employee=>empl_data_t. DATA error_t TYPE

string_table. START-OF-SELECTION.

DATA(all_employees_t) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ).

LOOP AT all_employees_t REFERENCE INTO DATA(dref).


TRY.
INSERT NEW lcl_employee( dref->* )->get_data( ) INTO TABLE extract_t.

"This ?me around it was not handled as a Resumable Excep?on


CATCH cx_no_data_found INTO DATA(lx_no_data). "<--Handled normally error_t = VALUE #( BASE error_t (
lx_no_data->get_text( ) ) ).
ENDTRY. ENDLOOP.

cl_demo_output=>new( )->write( extract_t )->write( error_t )->display( ).

– Changes to the Non-Resumable Excep-on handling


Now the implementa?on for the calling program (the consumer) needs to change to accommodate the changes to the
business requirement.

The developer who did not use the Resumable op?on has to now modify the processing logic of the consumer to
accommodate the changes in the business requirement.

Report ztest_new.

DATA extract_t TYPE lcl_employee=>empl_data_t.


DATA error_t TYPE string_table.
START-OF-SELECTION.

DATA(all_employees_t) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ).

LOOP AT all_employees_t REFERENCE INTO DATA(dref).

TRY.
INSERT VALUE #(
LET ref = NEW lcl_employee( dref->* ) IN empid = ref-
>get_emp_id( ) emptyp = ref->get_emptyp( ) phone = ref-
>get_phone( ) salary = ref->get_salary( )
)
INTO TABLE extract_t.

CATCH cx_no_data_found INTO DATA(lx_no_data).


error_t = VALUE #( BASE error_t ( lx_no_data->get_text( ) ) ).
ENDTRY.

ENDLOOP.

cl_demo_output=>new( )->write( extract_t )->write( error_t )->display( ).

As seen, there is a difference between raising and handling of an excep?on object with and without the Resumable
addi?on/op?on. There are also benefits of using Resumable excep?ons to simplify developments.

Resumable op?on of the Excep?on object is a powerful feature and they are extremely flexible yet simple to implement.
They can save developers a lot of ?me and effort especially in regards to reusability of common objects / framework in the
system as well as simplifying implementa?ons across the SAP system landscape.

What is a Separa>on of Concern (SoC)?


As the name suggests, it is a clear separa?on of concerns between the different objects in an applica?on. “It is a design
principle for separa?ng a computer program into dis?nct sec?ons such that each sec?on addresses a separate concern” –
Wikipedia.

– But why do we need SoC in our developments?


Simply to manage the different objects in a much beeer way within a single applica?on i.e. to make sure each object only
does what it is supposed to do and nothing more (or nothing less) and also to keep a clear separa?on between them i.e.
their own business logic. This principle allows developers freedom not only to manage those objects beeer but also to
simplify the build that makes it much more maintainable within the applica?on lifecycle. Let me provide some examples on
the concept of SoC:

– Real World example on the concept of SoC


Imagine a number of Rooms on an empty block. Each room has four walls, a roof and a door and there are people living in
them. People in each room do not know how the other room is (messy or organised, clean or dirty, its dimensions, the
furniture or anything about the other people living in them). The only way to know anything about any other room is to
enter through its door. To put it in the context, the rooms are the Objects, the furniture, its dimensions, the people living in
it etc. are its Aeributes, the fact that people in each room manages their own business (room) is the core concept of a SoC
and the door is the Interface via which the rooms communicate with each other to exchange informa?on.

– Example of SoC in an Applica?on


Say an applica?on has two objects; an Employee object and an User object. An Employee is employed by the organisa?on
whereas an User is an (system) User ID to be able to login to a par?cular system. It’s very easy to mix them up and we o_en
see (even senior) developers will fall into the trap of building a single object and within it will process the user data as well
as the employee data. That is a direct viola?on of the SoC principle – it may look harmless in the beginning but it is
poten?ally expensive within the applica?on lifecycle as we will see later in this blog series.

Smart developers, of course, will have these two (data provider) objects (concerns) separated hence applying the SoC
principle which we will explore soon in this blog.

Business Requirement (extended)


The business requirement is more or less the same as in the previous blog except some system User data is addi?onally
requested in the same report. Assume that the source of the Employee data is database Z1 and source of the User data is
database Z2 in this system.

The solu?on architect has also pointed out to the developers that he would like the implementa?on to adhere to the SoC
principle for ease of future extensibility and maintenance and therefore would like it to be well encapsulated.

Technical Design
Our smart developer, Emily, puts some effort in thinking in order to conceptualise the design prior to implementa?on while
our boring (and lazy) developer, Bob, does not think; he quickly starts implemen?ng it without any design.

The first thing that Emily thinks of is that a separa?on of business logic is necessary to achieve the SoC and perhaps she
could separate the Employee object, the User object and finally the caller/consumer i.e. the report itself could be separated
as well to establish a clear separa?on between the different objects in play.

Emily quickly comes up with a design idea of having an (common) Interface between the Employee and the User objects in
order to exchange data between them. Emily is sure that the Interface will be useful when another master data object
comes into the scope in the future; it would perhaps be worth the ?me in building it now as it has a strong poten?al for
reuse as the number of applica?ons con?nue to grow within the system landscape.

Implementa>on (with SoC)


Emily designs the Interface with two method defini?on; SET_DATA( ) with the idea that the implemen?ng Class will set the
data with its business logic to its own Private Sec?on and GET_DATA( ) which will return this data to any consumer (calling
program) in a generic way. She implements it as a Global Interface.

INTERFACE zif_masterdata.
METHODS set_data RETURNING VALUE(masterdata) TYPE REF TO zif_masterdata
RAISING RESUMABLE(cx_no_data_found).
METHODS get_data EXPORTING result TYPE any
RETURNING VALUE(masterdata) TYPE REF TO zif_masterdata. ENDINTERFACE.

She adds the Interface Usage in the (data) provider classes.

CLASS lcl_employee DEFINITION FINAL CREATE PUBLIC. " Interface Usage added
PUBLIC SECTION.
INTERFACES zif_masterdata.

The implementa?on of the Employee object is more or less the same (as in the Part 1 of this blog) except she now
implements the two new methods of the above Interface. As a result of the Interface usage, the Public Method GET_DATA
in the previous version has become redundant; Emily deletes it.

CLASS lcl_employee IMPLEMENTATION.


METHOD zif_masterdata~set_data.
me->empl_data = VALUE #(
empid = me->get_emp_id( ) emptyp = me-
>get_emptyp( ) salary = me->get_salary( ) phone =
me->get_phone( )
). masterdata = me.
ENDMETHOD.

METHOD zif_masterdata~get_data. result = me-


>empl_data. masterdata = me.
ENDMETHOD.
ENDCLASS.

Emily then implements the User object using the same Interface:
CLASS lcl_user DEFINITION FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES zif_masterdata.

TYPES: BEGIN OF ty_data, userid TYPE


string, role TYPE string, END OF
ty_data.

METHODS constructor IMPORTING i_empid TYPE int4.

PRIVATE SECTION.
DATA emp_id TYPE int4.
DATA user_data TYPE ty_data. ENDCLASS.

CLASS lcl_user IMPLEMENTATION.


METHOD constructor.
me->emp_id = i_empid. ENDMETHOD.

METHOD zif_masterdata~set_data. me-


>user_data = VALUE #(
userid = SWITCH #( me->emp_id WHEN 1
THEN |USER001|
WHEN 2 THEN |USER002|
WHEN 3 THEN |USER003|
WHEN 4 THEN |USER004|
WHEN 5 THEN |USER005|
ELSE THROW RESUMABLE cx_no_data_found(
rel_proc_id = CONV #( me->emp_id ) )
)
role = SWITCH #( me->emp_id
WHEN 1 THEN |Business Analyst|
WHEN 2 THEN |Configurer|
WHEN 3 THEN |Developer|
"WHEN 4 THEN |User|
WHEN 5 THEN |Tester|
ELSE THROW RESUMABLE cx_no_data_found(
rel_proc_id = CONV #( me->emp_id ) ) )
). masterdata = me.
ENDMETHOD.

METHOD zif_masterdata~get_data. result = me-


>user_data. masterdata = me.
ENDMETHOD. ENDCLASS.

She defines the Consumer (caller) object as a Global Class without marking it as FINAL so it can be reused (Inherited) in the
future if required – for this reason she moves some of the Private Aeributes to the Protected Sec?on (we will find out why
in the next/concluding blog of this series).

CLASS zcl_report DEFINITION PUBLIC CREATE PUBLIC.

PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.

TYPES: BEGIN OF extract,


empid TYPE int4, "Employee ID emptyp TYPE string, "Org Assignment
data
salary TYPE decfloat16, "Pay data phone TYPE numc10, "Communica?on data
userid TYPE string, "System User ID role TYPE string, "System Role END OF extract,
ey_extract TYPE SORTED TABLE OF extract WITH UNIQUE KEY empid.

CLASS-METHODS create IMPORTING


i_all_instances_t TYPE int4_table
RETURNING
VALUE(report) TYPE REF TO zcl_report.

METHODS process RETURNING VALUE(report) TYPE REF TO zcl_report.

PROTECTED SECTION.
DATA all_instances_t TYPE int4_table.
DATA error_t TYPE string_table.

METHODS get_data RETURNING VALUE(report) TYPE REF TO zcl_report. METHODS get_errors


RETURNING VALUE(rt_result) TYPE string_table.

PRIVATE SECTION.
DATA extract_t TYPE ey_extract.

ENDCLASS.

She then proceeds to implement the Global Class.

CLASS zcl_report IMPLEMENTATION.

METHOD create.
report = NEW zcl_report( ). report->all_instances_t = i_all_instances_t. ENDMETHOD.

METHOD process.

DATA empl_data TYPE lcl_employee=>ty_data.


DATA user_data TYPE lcl_user=>ty_data.

LOOP AT me->all_instances_t ASSIGNING FIELD-SYMBOL(<instance>).


TRY. me->extract_t =
VALUE #(
LET o_employee = NEW lcl_employee( employee )->zif_masterdata~set_data( ) if_empl
= o_employee->get_data( IMPORTING result = empl_data ) o_user = NEW lcl_user( employee
)->zif_masterdata~set_data( ) if_user = o_user->get_data( IMPORTING result = user_data )
IN BASE me->extract_t
( CORRESPONDING #( CORRESPONDING extract(
BASE ( CORRESPONDING extract( empl_data ) ) user_data ) ) ) ).

CATCH BEFORE UNWIND cx_no_data_found INTO DATA(lx_no_data_found).


IF lx_no_data_found->is_resumable = abap_true.
RESUME.
ELSE. me->error_t = VALUE #( BASE me->error_t ( lx_no_data_found->get_text( )
) ).
ENDIF.
ENDTRY. ENDLOOP.

report = me.
ENDMETHOD.

METHOD get_errors.
rt_result = me->error_t. ENDMETHOD.

METHOD get_data. report = me. ENDMETHOD.

METHOD if_oo_adt_classrun~main.
DATA(lo_report) = zcl_report=>create( VALUE #( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) )
)->process( ).

out->begin_sec?on( |DATA| )->write( lo_report->get_data( )->extract_t


)->begin_sec?on( |ERRORS| )->write( lo_report->get_errors( ) ).

ENDMETHOD.

ENDCLASS.

Implementa>on (without SoC)


Bob avoids crea?ng so many objects, a new interface and so on as he believes its “too much” to do to achieve such a
simple requirement; he does not understand why and what all this fuss is about!
He however liked the way Emily had implemented the Resumable Excep?ons (in Part 1 of this blog series) so he decides to
follow her design and proceeds to implement the addi?onal requirements by adding two new methods to the exis?ng class
which will provide for the system user data of the employee.

CLASS lcl_employee DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION.

* He extends the data structure by adding two new fields TYPES: BEGIN OF empl_data,
empid TYPE int4, "Employee ID emptyp TYPE string, "Org Assignment data
salary TYPE decfloat16, "Pay data phone TYPE numc10, "Communica?on data userid TYPE
string, "System User ID role type string, "System Role END OF empl_data, empl_data_t TYPE
SORTED TABLE OF empl_data WITH UNIQUE KEY empid.

PRIVATE SECTION.
* And adds two new methods for the addi?onal requirement METHODS get_userid RETURNING
VALUE(r_result) TYPE string RAISING RESUMABLE(cx_no_data_found).
METHODS get_role RETURNING VALUE(r_result) TYPE string RAISING
RESUMABLE(cx_no_data_found). ENDCLASS.

CLASS lcl_employee IMPLEMENTATION.


METHOD get_userid. r_result = SWITCH #( me->get_emp_id( )
WHEN 1 THEN |USER001|
WHEN 2 THEN |USER002|
WHEN 3 THEN |USER003|
WHEN 4 THEN |USER004|
WHEN 5 THEN |USER005|
ELSE THROW RESUMABLE cx_no_data_found(
rel_proc_id = CONV #( me->emp_id ) )
). ENDMETHOD.

METHOD get_role. r_result = SWITCH #( me->get_emp_id( )


WHEN 1 THEN |Business Analyst|
WHEN 2 THEN |Configurer|
WHEN 3 THEN |Developer|
"WHEN 4 THEN |User|
WHEN 5 THEN |Tester|
ELSE THROW RESUMABLE cx_no_data_found( rel_proc_id = CONV #(
me->emp_id ) )
).
ENDMETHOD.
ENDCLASS.

He then extends the GET_DATA( ) method to bring in the two new fields.

METHOD get_data. rs_result = VALUE #( empid = me-


>get_emp_id( ) emptyp = me->get_emptyp( )
salary = me->get_salary( ) phone = me-
>get_phone( ) userid = me->get_userid( )
role = me->get_role( )
). ENDMETHOD.

And finally he reviews the calling program – he is very happy to see that no changes are required here.

DATA extract_t TYPE lcl_employee=>empl_data_t. DATA error_t TYPE

string_table. START-OF-SELECTION.

DATA(all_employees_t) = VALUE int4_table( ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) ).

LOOP AT all_employees_t REFERENCE INTO DATA(dref).


TRY.
INSERT NEW lcl_employee( dref->* )->get_data( ) INTO TABLE extract_t.

CATCH BEFORE UNWIND cx_no_data_found INTO DATA(lx_no_data).


IF lx_no_data->is_resumable = abap_true.
RESUME.
ELSE.
error_t = VALUE #( BASE error_t ( lx_no_data->get_text( ) ) ).
ENDIF.
ENDTRY. ENDLOOP.

cl_demo_output=>new( )->write( extract_t )->write( error_t )->display( ).

Object oriented principle of Separa?on of Concern (SoC) can be used within our applica?ons no?cing the differences in their
technical designs and implementa?ons. For the SoC implementa?on, simplify the design by introducing an Interface
between the mul?ple objects at play in our applica?on and finally we used encapsula?on to achieve the exchange of data
between the different objects (concerns) with the help of a global Interface.

ABAP development tools for Eclipse!


This year the ABAP development tools for Eclipse (ADT) is celebra?ng its 10 years jubilee. One successful decade is over and
the path to the future is s?ll with the Eclipse-based ABAP IDE! Congratula?ons!

Meanwhile the ABAP development tools for Eclipse has made its way to become a very efficient, mature and feature rich
development environment for all ABAP-based development tasks as well on-premise for classic SAP Business Suite and new
SAP S/4HANA product families as in the cloud for SAP BTP ABAP Environment or SAP S/4HANA Private Cloud Edi?on
and SAP S/4HANA Public Cloud (by means of developer extensibility, see also the SAP S/4HANA Cloud ABAP Environment
community).

As of today the wide scope of the ABAP development tools for Eclipse capabili?es ranges from the modern development
toolset to the robust and reliable quality assurance and supportability tools.
From the very first versions the ABAP development tools for Eclipse already had a rich set of features for the efficient ABAP
development but there was s?ll some room for improvement. This short summary of the features highlights demonstrates
what has happened in these 10 years:

For your convenience here is a selec?on of materials, which should support you to get easy start and work effec?vely with
the ABAP development tools for Eclipse.

Download ABAP development tools for Eclipse


Simply go to the update site of the SAP Development Tools for Eclipse for ABAP and follow the installa?on instruc?ons.

ABAP Development User Guide


To get started with ABAP development tools for Eclipse we recommend the ABAP Development User Guide. If you have
already installed the ABAP development tools for Eclipse you can access it under the Help -> Help Contents -> SAP ABAP
Development User Guide.

To be especially highlighted are the ADT Basics Tutorial for beginners and Tips and Tricks to make your daily work easier. You
can also get there the overview of the most useful Keyboard Shortcuts. To support your smooth transi?on from the ABAP
Workbench we offer the FAQs for the SE80 Experts using ADT.

Quick Launch page


This Quick Launch page aims to provide you with the compact knowledge you may need when star?ng to work with the
ABAP development tools for Eclipse.

SAP Tutorials for Developers


In the developer center check the available SAP Tutorials for developers with the focus on the ABAP Development Tools in
Eclipse.
ADT Videos on YouTube
This ABAP in Eclipse playlist offers short feature videos about ABAP development tools for Eclipse

Features Availability Matrix


With the ABAP development tools for Eclipse we follow the strategy that the latest ADT client is compa?ble with all ABAP
backends with version 7.31 SP4 and higher. Get an overview about which features of the ABAP development tools for
Eclipse are available against which ABAP backend system in the ADT Features Availability Matrix.

FAQs
The most important ABAP development tools for Eclipse ques?ons and answers are collected in the FAQs – ABAP
development tools for Eclipse

Release Notes
Here are the Release Notes of ABAP development tools for Eclipse.

You might also like