WP02 - D Developing With ABAP in Eclipse
WP02 - D Developing With ABAP in Eclipse
2
INTRODUCTION
This document explains the steps required to complete all the activities planned for the current work package.
In this work package you will install the ABAP Development Tools in Eclipse and understand basics of developing ABAP in Eclipse.
3
PREREQUISITES – ECLIPSE AND ADT INSTALLATION
In this section we will explain the main steps to install Eclipse IDE and the ABAP Development Tools.
1. Install a JVM
Installation of a Java virtual machine (JVM) is required for you to make use of Eclipse IDE.
Depending on your preferences you may choose to install either a Java Runtime Environment (JRE), or a Java Development Kit (JDK), installing a JDK is the preferred option
by most developers but if you wish to save some disk space you may install a JRE.
The required JDK/JRE version for the latest Eclipse release must be a 64-bit JVM with Java 11.
See SAP Note 2949356 2949356 - Java 11 is mandatory for ADT in February 2021 for details.
Once you have installed the JVM you may proceed with the installation of Eclipse IDE.
4
2. Install Eclipse IDE
There are 5 steps to install Eclipse IDE via the Eclipse Installer, you can follow the steps described in the following installation guide:
https://www.eclipse.org/downloads/packages/installer
When prompted for Eclipse version selection, choose “Eclipse IDE for Java EE Developers”, installer should then download the required components and run the
installation successfully.
5
3. Configure JVM in eclipse
In order to ensure that Eclipse is using the JVM that you have downloaded and to avoid interference by any other software installed in your system it is highly recommended
you configure Eclipse with the specific JVM you need.
To do this, you must modify the Eclipse.ini file in your installation folder. You can find the instructions to modify this file in all major OS versions in the following link:
https://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM
a) In Eclipse, choose in the menu bar Help > Install New Software...
b) Add the URL https://tools.hana.ondemand.com/latest
c) Press Enter to display the available features.
d) Select ABAP Development Tools and choose Next.
e) On the next wizard page, you get an overview of the features to be installed. Choose Next.
f) Confirm the license agreements and choose Finish to start the installation
**NOTE:
Further information about Eclipse and ADT installation, including troubleshooting and know issues can be found in the ABAP Development Tools Installation
Guide
6
DEVELOPMENT BASICS
You can find the step-by-step exercise in this document in the third chapter.
The ABAP Development Tools (ADT) for SAP NetWeaver, also known as "ABAP in Eclipse", is the recommended IDE for developing ABAP applications. It is available
from SAP NetWeaver 7.31 SP4 onwards and it integrates seamlessly into your existing ABAP development systems. In this series of exercises, you will get an
introduction to the powerful tools delivered with ADT and experience the advantages of using ABAP in Eclipse for your ABAP developments.
All the solutions to the exercises are provided as a reference - this way you can also see the solutions for the exercises you did not finish. Feel free to experiment with
the IDE yourself. These exercises are only a guideline.
The exercises are based on the demo tables of the SAP NetWeaver EPM Model (you can find details in the SCN http://scn.sap.com/docs/DOC-31458 ). So you can
reiterate the exercises on any SAP NetWeaver 7.40 or later systems.
Objective
In this exercise you will learn how to use ABAP in Eclipse. You will create an ABAP Project, use the Data Preview and SQL Console and implement and run an ABAP
Application. You will also learn how to use Quick Assists to speed up your development.
Exercise Description:
• Open ABAP in Eclipse
• Create an ABAP Project
• Use the Data Preview and the SQL Console
• Create and run an ABAP Program
• Create a global ABAP Class for data retrieval
7
Open ABAP in Eclipse
Step/Comments Screenshot
1. Start Eclipse
8
2. Accept the proposed
workspace / choose your
own workspace.
9
3. Close the Welcome page.
10
Step/Comments Screenshot
11
6. Select the entry
ABAP to
open the ABAP perspective
with the ABAP development
tools.
12
Project Explorer View
Provides a hierarchical view of your ABAP Projects. From here you can browse the ABAP Development Objects in the ABAP system (similar to the
After starting the IDE and Repository Browser in the Object Navigator (SE80)) and open your ABAP Development Objects in the corresponding editor.
opening the ABAP perspective, Editors Area
the ABAP tools are ideally The editors for the ABAP Development Objects are opened in the area reserved in the centre of the IDE.
Outline View
positioned in the IDE to This view displays a structured overview of the ABAP Development Object that is currently open in the editor area. The contents of the outline
facilitate your development view are editor-specific.
tasks. Nevertheless you are Feature Explorer View
free to rearrange all views and This view provides you with an interactive tutorial to help you get familiar with the basic features in ABAP in Eclipse.
Other Views
editors to your personel needs.
Several other useful views are stacked underneath the editor area in a tabbed container. Two of the most commonly used views are the:
• Problems View: This view displays the syntax errors, warnings or other information associated with an ABAP Development Object
Project Explorer View (typically opened in the editor area)
Provides a hierarchical view of your • Properties View: This view displays the basic properties of the ABAP Development Object that is currently open in the editor area, e.g.:
ABAP Projects. From here you can "Last changed by", "Created on", etc.
browse the ABAP Development
Objects in the ABAP system (similar to
the Repository Browser in the Object
Navigator (SE80)) and open your
ABAP Development Objects in the
corresponding editor.
Editors Area
The editors for the ABAP
Development Objects are opened in
the area reserved in the centre of the
IDE.
Outline View
This view displays a structured
overview of the ABAP Development
Object that is currently open in the
editor area. The contents of the outline
view are editor-specific.
Feature Explorer View
This view provides you with an
interactive tutorial to help you get
familiar with the basic features in
ABAP in Eclipse.
Other Views
Several other useful views are stacked
underneath the editor area in a tabbed
container like transport organizer,
bookmarks, tasks and so on.
13
Step/Comments Screenshot
8. Click New
9. Click the ABAP
Project
14
Step/Comments Screenshot
12. Enter your developer ID
(e.g. 5STEPS2FIORI) in the
User: * box.
15
14. Your ABAP Project has
been created and you have
successfully logged on to the
ABAP system. Your ABAP
Project is visible in the Project
Explorer.
16
Use the Data Preview & the SQL Console
Step/Comments Screenshot
17
2. Enter snwd_so_inv_item in
the search field.
4. Press to open
the Data Preview.
18
Step/Comments Screenshot
6. First click Deselect All.
8. and CURRENCY_CODE.
9. Press to confirm
your selection.
19
10. Press Add filter and...
11. choose
CURRENCY_CODE.
20
Step/Comments Screenshot
13. to open
the SQL Console.
21
Adjust the select statement in SQL
Console in order to get the
payment status from the order
header by doing the following:
22
Step/Comments Screenshot
18. Check that the output on
the right hand side contains the
payment status.
23
22. Click .
24
Create and run an ABAP Program
Step/Comments Screenshot
1. Right click on Logical
Objects ($TMP)
25
2. Search and select
ABAP Program
menu item.
3. Enter
Z_INVOICE_ITMES_EURO_<
NN> in the Name: * box.
Please refer to the Setup-
Information and exchange
_<NN> with your user number.
5. Click Finish .
26
6. Type lcl and press
Ctrl+Space to get code
completion proposals.
27
Step/Comments Screenshot
8. Adjust the name of the local
class to lcl_main using inline
editing.
28
10. Add the defintion of an
additional instance method run
in the public section.
29
14. Click Activate
(Ctrl+F3) .
30
Step/Comments Screenshot
31
17. Click the [F00]
Z_INVOICE_ITMES_EURO_<
NN>
32
Create a global ABAP Class for data retrieval
In this part of the exercise, you will replace the write statement in your report with data retrieval logic based on the select statement created before in the SQL
Console. Then you will display the retrieved data using the SAP ABAP List Viewer (ALV). In order to separate concerns properly and to show you a wider toolset the
data retrieval logic will be encapsulated in a global ABAP class.
Step/Comments Screenshot
1. First remove the write
statement. Place the cursor
somewhere in the write
statement and use the shortcut
Ctrl+D to delete the whole line.
33
4. Enter
ZCL_INVOICE_RETRIEVAL_
NN in the Name: * box.
Replace NN with your user
number.
6. Click Finish .
34
Step/Comments Screenshot
A new editor will be
opened showing the created class.
35
11. Click Finish to confirm the
creation of
get_items_from_db as a
public method without
parameters.
36
Step/Comments Screenshot
12. A method definition and...
37
14. Add an ABAP Doc comment to
the newly created method definition.
38
On the bottom left hand side of the SQL
console is the query section. It contains
the last executed select statements as
Open SQL statements ready to be
transferred into your ABAP code.
39
Step/Comments Screenshot
17. Paste the statement into
the method implementation of
get_items_from_db. Add the
ABAP statement terminator
(period character) at the end of
the statement to ensure that it
is syntactically correct.
40
Since there are no formatting
settings defined for your user on
the ABAP server a dialog appears
which allows you to maintain these
settings.
41
This takes you to the
corresponding page in the
properties dialog of the project.
42
Step/Comments Screenshot
24. Trigger
source formatting again by
pressing Shift+F1.
43
26. Add some line breaks in the
join conditions to make the
select statement more
readable.
44
The method still doesn't deliver
any result data. You will now
execute a sequence of quick
assists to transform the inline
declared variable lt_result into a
fully typed returning parameter.
45
Step/Comments Screenshot
46
The Quick Assist moved the
helper type from inside the method
implementation into the private
section. In order to use this type
for a parameter of your public
method get_items_from_db the
type should be moved into the
public section. Let's see if we can
find a Quick Assist for that.
47
Step/Comments Screenshot
48
38. Back in the report position
the cursor on the method call
get_items_from_db and Press
F2 to see the Element Info of
the method. In addition to the
method signature it also shows
the ABAP Doc you wrote
before.
49
Step/Comments Screenshot
press Ctrl+Space to get code completion proposals.
50
44. In the generated method call...
• Remove the commented importing parameters
list_display, r_container, and container_name
using the shortcut Ctrl+D
• Uncomment the exporting parameter
r_salv_table using the shortcut Ctrl+7 and
assign it to an inline variable alv_table
• Assign the variable invoice_items to the
changing parameter t_table
51
Step/Comments Screenshot
45. Finally, call the display
method of alv_table.
52
49. Go back to your invoice
retrieval class and adjust the
payment_status component of
the helper_type so that it can
hold 10 characters.
53
51. Activate the class
by clicking or use the
shortcut Ctrl+F3.
54
Step/Comments Screenshot
55
You have completed the exercise!
56
Using Core Data Services Views
Overview
Estimated time: 30 minutes
Objective
In the following exercise you will learn how to use the new Core Data Services (CDS) tools in ABAP in Eclipse. CDS is an extension of the ABAP Dictionary that
allows you to define semantically rich data models in the database and to use these data models in your ABAP programs. CDS is a central part of enabling Code
Pushdown in ABAP applications.
You will learn to define a new CDS view in a DDL source and to consume the CDS view in the SAP List Viewer with Integrated Data Access (ALV with IDA). Using
ALV with IDA it is possible to display views and tables that contain very large quantities of data in the UI. You will also learn about some of the CDS enhanced view-
building capabilities such as associations and annotations.
You can find more information about CDS and ALV with IDA in the SAP Help Portal (help.sap.com) and the SAP Community Network (scn.sap.com).
Exercise Description
57
Create a CDS View
Step/Comments Screenshot
1. In the context menu of your
Local Objects $TMP package select New and
then click Other ABAP Repository Object.
58
Step/Comments Screenshot
2. Enter ddl in the text field and
click Data Definition.
3. Click .
59
4. Check that $TMP is filled in
the Package:
* box.
5. Enter
Z_INVOICE_ITEMS_NN in the
Name: * box. Replace NN with
your user number.
7. Click Next .
8. Click Next .
60
Step/Comments Screenshot
9. Select the Define View
template by clicking Define
View
61
11. Enter
ZINVOICEITEMS_NN for the
SQL view name. Replace NN
with your user number.
13. Double-click on
62
Step/Comments Screenshot
63
CDS associations model the
relationships between data
sources. You can use associations
and path expressions to access
fields in related data sources
without specifying JOIN
conditions.
64
Step/Comments Screenshot
65
21. Save the DDL source. Click
Save (Ctrl+S) .
66
Step/Comments Screenshot
23. Open the Data Preview for
your CDS view. Press F8.
67
The invoice items are displayed in
the Data Preview.
68
Use the CDS View in ALV with IDA
Step/Comments Screenshot
1. In the context menu of the
program
Z_INVOICE_ITEMS_EURO<N
N> click Duplicate....
3. Click Finish .
69
Replace the implementation of the
run method. Create an ALV with
IDA for your CDS View
Z_Invoice_Items_Nn (Nn
represents your user number) and
display the ALV with IDA in
fullscreen.
DATA(alv_display) =
cl_salv_gui_table_ida=>create_for
_cds_view(
'Z_INVOICE_ITEMS_NN' ).
alv_display->fullscreen( )->display(
).
70
Step/Comments Screenshot
7. Click .
71
8. Select ISO Currency Code.
Add the column to the Filter
criteria. Click .
72
Step/Comments Screenshot
9. Set the filter values. Click
.
73
10. Enter EUR for the ISO
Currency Code filter criteria.
11. Click .
74
The filtered invoice items are
displayed in ALV with IDA.
75
Step/Comments Screenshot
13. Click the [FXX]
Z_INVOICE_ITEMS_NN
tab to
open the DDL editor.
76
18. Press F8 to execute the
program.
77
Step/Comments Screenshot
78
www.sap.com/contactsap
© 2021 SAP SE or an SAP affiliate company. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.
The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product
specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if
any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This
document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by
SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-
looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, and
they should not be relied upon in making purchasing decisions.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. All other product
and service names mentioned are the trademarks of their respective companies. See www.sap.com/trademark for additional trademark information and notices.
. All other product and service names mentioned are the trademarks of their respective companies. See http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and notices.